realroot_doc 0.1.1
|
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().
: _size(s){ // cout <<"C "<<s<<endl; _tab = dynamic_exp<E>::alloc(s); for(int i=0;i<s;i++) _tab[i]=(exponent_t)0; // cout <<*this<<endl; }
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().
{return (new E[N]);}
iterator begin | ( | ) | [inline] |
Definition at line 77 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
const_iterator begin | ( | ) | const [inline] |
Definition at line 78 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
{return const_iterator(_tab); }
void clear | ( | ) | [inline] |
Definition at line 185 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
Referenced by mmx::erase().
{delete[] _tab;}
iterator end | ( | ) | [inline] |
Definition at line 79 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, and dynamic_exp< E >::_tab.
const_iterator end | ( | ) | const [inline] |
Definition at line 80 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, and dynamic_exp< E >::_tab.
{return const_iterator(_tab+_size); }
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().
{ if (_size) { delete [] _tab; } _size= s; _tab = dynamic_exp<E>::alloc(s); }
Definition at line 94 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, dynamic_exp< E >::_tab, and dynamic_exp< E >::alloc().
{ if (&A == this) { return *this; } if (_tab != NULL) { // cout << "sz = " << sizeof( _tab) << " " << _size << endl; // for (int kk = 0; kk < _size; ++kk) { // cout << _tab[kk] << " "; // } cout << endl; delete [] _tab; } _size = A._size; if (_size) { _tab = dynamic_exp<E>::alloc(_size); memcpy(_tab,A._tab,sizeof(E)*_size); } else _tab = NULL; return *this; }
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.
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.
reverse_iterator rbegin | ( | ) | [inline] |
Definition at line 82 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, and dynamic_exp< E >::_tab.
{return reverse_iterator(_tab+_size); }
const_reverse_iterator rbegin | ( | ) | const [inline] |
Definition at line 83 of file dynamicexp.hpp.
References dynamic_exp< E >::_size, and dynamic_exp< E >::_tab.
{return reverse_iterator(_tab+_size); }
reverse_iterator rend | ( | ) | [inline] |
Definition at line 84 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
{return reverse_iterator(_tab); }
const_reverse_iterator rend | ( | ) | const [inline] |
Definition at line 85 of file dynamicexp.hpp.
References dynamic_exp< E >::_tab.
{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().
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 | ||
) |
Definition at line 217 of file dynamicexp.hpp.
References assert.
{ assert(i<_size); (*this)[i]=d; // while(_tab[_size-1]==0 && _size>0) _size--; // if (i < 0); // else if (i+1 < _size) // _tab[i] = d; // else if (i >= _size && d) { // E* aux = dynamic_exp<E>::alloc(i+1); // memset(aux,0,sizeof(E)*(i+1)); // memcpy(aux,_tab,sizeof(E)*_size); // //memset(aux+size,0,i-size); // aux[i] = d; // delete [] _tab; // _tab = aux; // //realloc(_tab,sizeof(E)*(i+1)); // //memset(_tab+size,0,i-size); // //_tab[i] = d; // _size = i+1; // } // else if (i >= _size && !d); // else if (d) // _tab[i] = d; // else { // int j = i - 1; // while (j >= 0 && !_tab[j]) --j; // _size = j+1; // if (j < 0) { // clear(); // _tab = NULL; // } // else { // E * aux = dynamic_exp<E>::alloc(j+1); // memcpy(aux,_tab,sizeof(E)*(j+1)); // clear(); // _tab = aux; // } // } return *this; }
size_type size | ( | void | ) | const [inline] |
Definition at line 75 of file dynamicexp.hpp.
References dynamic_exp< E >::_size.
Referenced by mmx::add().
{return _size;}
bool operator!= | ( | const dynamic_exp< E > & | A, |
const dynamic_exp< E > & | B | ||
) | [friend] |
Definition at line 175 of file dynamicexp.hpp.
{
return !(A==B);
}
bool operator== | ( | const dynamic_exp< E > & | A, |
const dynamic_exp< E > & | B | ||
) | [friend] |
Definition at line 156 of file dynamicexp.hpp.
{ int i,minsize=std::min(A._size,B._size); for(i=0;i<minsize;i++) if(A._tab[i]!=B._tab[i]) return 0; if(A._size>B._size) { for(;i<(int)A._size;i++) if(A._tab[i]) return 0; } else { for(;i<(int)B._size;i++) if(B._tab[i]) return 0; } // if (A._size == B._size) // return memcmp(A._tab,B._tab,sizeof(E)*A._size) == 0; return 1; }
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(), 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().