Dynamic exponent. More...
#include <dynamicexp.hpp>
Dynamic exponent.
Definition at line 25 of file dynamicexp.hpp.
typedef iterator const_iterator |
Definition at line 30 of file dynamicexp.hpp.
typedef std::reverse_iterator<const_iterator> const_reverse_iterator |
Definition at line 31 of file dynamicexp.hpp.
typedef int degree_t |
Definition at line 35 of file dynamicexp.hpp.
typedef E exponent_t |
Definition at line 34 of file dynamicexp.hpp.
typedef E* iterator |
Definition at line 29 of file dynamicexp.hpp.
typedef std::reverse_iterator<iterator> reverse_iterator |
Definition at line 32 of file dynamicexp.hpp.
typedef dynamic_exp<E> self_t |
Definition at line 36 of file dynamicexp.hpp.
typedef unsigned int size_type |
Definition at line 28 of file dynamicexp.hpp.
typedef E value_type |
Definition at line 27 of file dynamicexp.hpp.
dynamic_exp | ( | ) | [inline] |
Definition at line 39 of file dynamicexp.hpp.
dynamic_exp | ( | const dynamic_exp< E > & | d | ) | [inline] |
Definition at line 40 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, dynamic_exp< E >::_tab, and dynamic_exp< E >::alloc().
dynamic_exp | ( | int | s | ) | [inline] |
Definition at line 51 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab, and dynamic_exp< E >::alloc().
00051 : _size(s){ 00052 // cout <<"C "<<s<<endl; 00053 _tab = dynamic_exp<E>::alloc(s); 00054 for(int i=0;i<s;i++) _tab[i]=(exponent_t)0; 00055 // cout <<*this<<endl; 00056 }
dynamic_exp | ( | int | s, | |
E * | t | |||
) | [inline] |
Definition at line 58 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, dynamic_exp< E >::_tab, dynamic_exp< E >::alloc(), and assert.
~dynamic_exp | ( | ) | [inline] |
Definition at line 73 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
static E* alloc | ( | unsigned int | N | ) | [inline, static] |
Definition at line 182 of file dynamicexp.hpp.
Referenced by dynamic_exp< E >::dynamic_exp(), dynamic_exp< E >::init(), dynamic_exp< E >::operator=(), dynamic_exp< E >::reserve(), and dynamic_exp< E >::resize().
00183 {return (new E[N]);}
const_iterator begin | ( | ) | const [inline] |
Definition at line 78 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
00078 {return const_iterator(_tab); }
iterator begin | ( | ) | [inline] |
Definition at line 77 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
void clear | ( | ) | [inline] |
Definition at line 185 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
Referenced by mmx::erase().
00185 {delete[] _tab;}
const_iterator end | ( | ) | const [inline] |
Definition at line 80 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, and dynamic_exp< E >::_tab.
00080 {return const_iterator(_tab+_size); }
iterator end | ( | ) | [inline] |
Definition at line 79 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, and dynamic_exp< E >::_tab.
void init | ( | int | s | ) | [inline] |
Definition at line 147 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, dynamic_exp< E >::_tab, and dynamic_exp< E >::alloc().
Referenced by mmx::add().
00148 { 00149 if (_size) { delete [] _tab; } 00150 _size= s; 00151 _tab = dynamic_exp<E>::alloc(s); 00152 }
Definition at line 94 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, dynamic_exp< E >::_tab, and dynamic_exp< E >::alloc().
00094 { 00095 if (&A == this) { return *this; } 00096 if (_tab != NULL) { 00097 // cout << "sz = " << sizeof( _tab) << " " << _size << endl; 00098 // for (int kk = 0; kk < _size; ++kk) { 00099 // cout << _tab[kk] << " "; 00100 // } cout << endl; 00101 delete [] _tab; 00102 } 00103 _size = A._size; 00104 if (_size) { 00105 _tab = dynamic_exp<E>::alloc(_size); 00106 memcpy(_tab,A._tab,sizeof(E)*_size); 00107 } 00108 else 00109 _tab = NULL; 00110 return *this; 00111 }
E& operator[] | ( | size_type | i | ) | [inline] |
Definition at line 91 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, dynamic_exp< E >::_tab, and assert.
E operator[] | ( | size_type | i | ) | const [inline] |
Definition at line 87 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, and dynamic_exp< E >::_tab.
const_reverse_iterator rbegin | ( | ) | const [inline] |
Definition at line 83 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, and dynamic_exp< E >::_tab.
00083 {return reverse_iterator(_tab+_size); }
reverse_iterator rbegin | ( | ) | [inline] |
Definition at line 82 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, and dynamic_exp< E >::_tab.
00082 {return reverse_iterator(_tab+_size); }
const_reverse_iterator rend | ( | ) | const [inline] |
Definition at line 85 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
00085 {return reverse_iterator(_tab); }
reverse_iterator rend | ( | ) | [inline] |
Definition at line 84 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
00084 {return reverse_iterator(_tab); }
void reserve | ( | size_type | s | ) | [inline] |
Definition at line 115 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, dynamic_exp< E >::_tab, and dynamic_exp< E >::alloc().
00116 { 00117 if (!s) { 00118 if (_size) { delete [] _tab; } 00119 _size = 0; 00120 _tab = NULL; 00121 } 00122 else if(_tab==NULL) { 00123 _size = s;_tab = dynamic_exp<E>::alloc(s); 00124 //for(size_type i=0;i<s;i++) _tab[i]=(exponent_t)0; 00125 } 00126 else { 00127 delete [] _tab; 00128 _tab = dynamic_exp<E>::alloc(s); 00129 _size=s; 00130 } 00131 }
void resize | ( | size_type | s | ) | [inline] |
Definition at line 132 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, dynamic_exp< E >::_tab, and dynamic_exp< E >::alloc().
dynamic_exp< E > & set_expt | ( | size_type | i, | |
value_type | d | |||
) | [inline] |
Definition at line 217 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, and assert.
00218 { 00219 assert(i<_size); 00220 (*this)[i]=d; 00221 00222 // while(_tab[_size-1]==0 && _size>0) _size--; 00223 00224 // if (i < 0); 00225 // else if (i+1 < _size) 00226 // _tab[i] = d; 00227 // else if (i >= _size && d) { 00228 // E* aux = dynamic_exp<E>::alloc(i+1); 00229 // memset(aux,0,sizeof(E)*(i+1)); 00230 // memcpy(aux,_tab,sizeof(E)*_size); 00231 // //memset(aux+size,0,i-size); 00232 // aux[i] = d; 00233 // delete [] _tab; 00234 // _tab = aux; 00235 // //realloc(_tab,sizeof(E)*(i+1)); 00236 // //memset(_tab+size,0,i-size); 00237 // //_tab[i] = d; 00238 // _size = i+1; 00239 // } 00240 // else if (i >= _size && !d); 00241 // else if (d) 00242 // _tab[i] = d; 00243 // else { 00244 // int j = i - 1; 00245 // while (j >= 0 && !_tab[j]) --j; 00246 // _size = j+1; 00247 // if (j < 0) { 00248 // clear(); 00249 // _tab = NULL; 00250 // } 00251 // else { 00252 // E * aux = dynamic_exp<E>::alloc(j+1); 00253 // memcpy(aux,_tab,sizeof(E)*(j+1)); 00254 // clear(); 00255 // _tab = aux; 00256 // } 00257 // } 00258 return *this; 00259 }
size_type size | ( | void | ) | const [inline] |
Definition at line 75 of file dynamicexp.hpp.
References dynamic_exp< E >::_size.
Referenced by mmx::add().
00075 {return _size;}
bool operator!= | ( | const dynamic_exp< E > & | A, | |
const dynamic_exp< E > & | B | |||
) | [friend] |
Definition at line 175 of file dynamicexp.hpp.
bool operator== | ( | const dynamic_exp< E > & | A, | |
const dynamic_exp< E > & | B | |||
) | [friend] |
Definition at line 156 of file dynamicexp.hpp.
00156 { 00157 int i,minsize=std::min(A._size,B._size); 00158 for(i=0;i<minsize;i++) 00159 if(A._tab[i]!=B._tab[i]) return 0; 00160 if(A._size>B._size) 00161 { 00162 for(;i<(int)A._size;i++) 00163 if(A._tab[i]) return 0; 00164 } 00165 else 00166 { 00167 for(;i<(int)B._size;i++) 00168 if(B._tab[i]) return 0; 00169 00170 } 00171 // if (A._size == B._size) 00172 // return memcmp(A._tab,B._tab,sizeof(E)*A._size) == 0; 00173 return 1; 00174 }
Definition at line 179 of file dynamicexp.hpp.
Referenced by mmx::degree(), dynamic_exp< E >::dynamic_exp(), dynamic_exp< E >::end(), mmx::erase(), dynamic_exp< E >::init(), mmx::lvar(), dynamic_exp< E >::operator=(), dynamic_exp< E >::operator[](), dynamic_exp< E >::rbegin(), dynamic_exp< E >::reserve(), dynamic_exp< E >::resize(), dynamic_exp< E >::set_expt(), and dynamic_exp< E >::size().
E* _tab |
Definition at line 180 of file dynamicexp.hpp.
Referenced by dynamic_exp< E >::begin(), dynamic_exp< E >::clear(), dynamic_exp< E >::dynamic_exp(), dynamic_exp< E >::end(), mmx::erase(), dynamic_exp< E >::init(), dynamic_exp< E >::operator=(), dynamic_exp< E >::operator[](), dynamic_exp< E >::rbegin(), dynamic_exp< E >::rend(), dynamic_exp< E >::reserve(), dynamic_exp< E >::resize(), and dynamic_exp< E >::~dynamic_exp().