2 #ifndef VSR_SET_H_INCLUDED
3 #define VSR_SET_H_INCLUDED
19 unsigned long mActiveId;
24 unsigned long& activeId() {
return mActiveId; }
25 unsigned long activeId()
const {
return mActiveId; }
28 Set& insert(T s) { mData.insert( mData.begin(), s); }
29 Set& pop() { mData.pop_back(); }
30 Set& add(T s) { mData.push_back(s); mActiveId = mData.size();
return *
this; }
35 Set& add(
const Set& s) {
for(
int i = 0; i < s.size(); ++i) add(s[i]); }
36 Set& erase(
int idx) { mData.erase( mData.begin() + idx ); }
37 Set& erase(
int b,
int e) { mData.erase( mData.begin() + b, mData.begin() + e ); }
39 Set& clear() { vector<T>().swap(mData);
return *
this; }
41 T& active() {
return mData[mActiveId-1]; }
42 T active()
const {
return mData[mActiveId-1]; }
44 T& operator [] (
int i) {
return mData[i]; }
45 T operator [] (
int i)
const {
return mData[i]; }
47 unsigned long size()
const {
return mData.size(); }
48 unsigned long num()
const {
return mData.size(); }
50 T * ptr() {
return &(mData[0]); }
51 T& last() {
return mData[mActiveId-1]; }
53 typename vector<T>::iterator begin() {
return mData.begin(); }
54 typename vector<T>::iterator end() {
return mData.end(); }
56 vector<T>& data(){
return mData; }
57 vector<T> data()
const {
return mData; }
76 T& data(
int idx) {
return mData[idx ]; }
77 T data(
int idx)
const {
return mData[idx ]; }
79 T * ptr() {
return mData; }
80 void ptr( T * d ) { mData = d; }
83 void setOffset() { mOffset =
sizeof(S) - mStride; }
85 Data(
int N=0) : mNum(N), mData(NULL) {
90 void num(
int N) { mNum = N; }
91 int num()
const {
return mNum; }
95 if (mData)
delete[] mData;
113 T * tmp = mPrev; mPrev = this->mData; this->mData = tmp;
116 T& prev(
int idx) {
return mPrev[idx]; }
117 T prev(
int idx)
const {
return mPrev[idx]; }
123 if (mPrev)
delete[] mPrev;
124 mPrev =
new T[this->mNum];
128 if (!mPrev) mPrev =
new T[this->mNum];
129 std::copy( this->mData, this->mData+this->mNum, mPrev);
134 template<
int N,
typename T>
140 void resize(
int n) { this->mNum = n; alloc(); }
146 std::copy( this->mData, this->mData + this->mNum, mNext.ptr() );
152 void resize(
int N) { this->mNum = N; alloc(); }
Definition: vsr_set.h:104
the versor library namespace
Definition: vsr_algebra.h:29
Definition: vsr_set.h:135