46   template<
class T, 
unsigned char pks = 5> 
class dynamic_tas;
 
   48   template<
class T, 
unsigned char pks = 5> 
struct dnt_iterator
 
   51     typedef value_type*   pointer;
 
   52     typedef value_type&   reference;
 
   54     typedef ptrdiff_t     difference_type;
 
   55     typedef std::bidirectional_iterator_tag iterator_category;
 
   57     typename dynamic_array<T,pks>::iterator id;
 
   58     bit_vector::iterator ib;
 
   62     dnt_iterator(dynamic_tas<T,pks> &da, bit_vector &bv, 
size_type ii)
 
   63       : id(da, ii), ib(bv, ii) { lt = da.index().last_true(); }
 
   65     inline size_type index(
void)
 const { 
return id.index(); }
 
   67     dnt_iterator &operator ++();
 
   68     dnt_iterator &operator --()
 
   69     { 
while (!*(--ib)) --id; --id; 
return *
this; }
 
   70     dnt_iterator operator ++(
int)
 
   71     {  dnt_iterator tmp = *
this; ++(*this); 
return tmp; }
 
   72     dnt_iterator operator --(
int)
 
   73     { dnt_iterator tmp = *
this; --(*this); 
return tmp; }
 
   75     difference_type 
operator -(
const dnt_iterator &i)
 const 
   79     reference operator *()
 const { 
return (*
id); }
 
   80     pointer operator->()
 const { 
return &(operator*()); }
 
   82     bool operator ==(
const dnt_iterator &i)
 const { 
return i.id==id;}
 
   83     bool operator !=(
const dnt_iterator &i)
 const { 
return i.id!=id;}
 
   84     bool operator < (
const dnt_iterator &i)
 const { 
return id < i.id;}
 
   85     bool operator > (
const dnt_iterator &i)
 const { 
return id > i.id;}
 
   86     bool operator >=(
const dnt_iterator &i)
 const { 
return id >= i.id;}
 
   89   template<
class T, 
unsigned char pks> dnt_iterator<T, pks> &
 
   90   dnt_iterator<T, pks>::operator ++()
 
   91   { ++ib; ++id; 
while(
id.in <= lt && !*ib) {++ib; ++id; } 
return *
this; }
 
   93   template<
class T, 
unsigned char pks = 5> 
struct dnt_const_iterator {
 
   95     typedef const value_type*   pointer;
 
   96     typedef const value_type&   reference;
 
   98     typedef ptrdiff_t           difference_type;
 
   99     typedef std::bidirectional_iterator_tag iterator_category;
 
  101     typename dynamic_array<T,pks>::const_iterator id;
 
  102     bit_vector::const_iterator ib;
 
  105     dnt_const_iterator(
void) {}
 
  106     dnt_const_iterator(
const dynamic_tas<T,pks> &da, 
size_type ii)
 
  107       : id(da, ii), ib(da.index(), ii) { lt = da.index().last_true(); }
 
  108     dnt_const_iterator(
const dnt_iterator<T,pks> &it)
 
  109       : id(it.id), ib(it.ib), lt(it.lt) { }
 
  111     inline size_type index(
void)
 const { 
return id.index(); }
 
  113     dnt_const_iterator &operator ++()
 
  114     { ++ib; ++id; 
while(
id.in <= lt && !*ib) {++ib; ++id; } 
return *
this; }
 
  115     dnt_const_iterator &operator --()
 
  116     { 
while (!*(--ib)) --id; --id; 
return *
this; }
 
  117     dnt_const_iterator operator ++(
int)
 
  118     {  dnt_const_iterator tmp = *
this; ++(*this); 
return tmp; }
 
  119     dnt_const_iterator operator --(
int)
 
  120     { dnt_const_iterator tmp = *
this; --(*this); 
return tmp; }
 
  122     difference_type 
operator -(
const dnt_const_iterator &i)
 const 
  123     { 
return id - i.id; }
 
  125     reference operator *()
 const { 
return (*
id); }
 
  126     pointer operator->()
 const { 
return &(operator*()); }
 
  128     bool operator ==(
const dnt_const_iterator &i)
 const 
  129     { 
return i.id == id;}
 
  130     bool operator !=(
const dnt_const_iterator &i)
 const 
  131     { 
return i.id != id;}
 
  132     bool operator < (
const dnt_const_iterator &i)
 const 
  134     bool operator > (
const dnt_const_iterator &i)
 const 
  136     bool operator >=(
const dnt_const_iterator &i)
 const 
  137     { 
return id >= i.id;}
 
  140   template<
class T, 
unsigned char pks> 
class dynamic_tas
 
  141     : 
public dynamic_array<T, pks> {
 
  146     typedef typename dynamic_array<T, pks>::iterator iterator;
 
  147     typedef typename dynamic_array<T, pks>::const_iterator const_iterator;
 
  148     typedef dnt_iterator<T, pks> tas_iterator;
 
  149     typedef dnt_const_iterator<T, pks> const_tas_iterator;
 
  150     typedef typename dynamic_array<T, pks>::size_type 
size_type;
 
  155     { 
return (ind.card() == 0) ? 0 : (ind.last_true() + 1); }
 
  157     { 
return (ind.card() == 0) ? 0 : ind.first_true(); }
 
  159     { 
return (ind.card() == 0) ? 0 : ind.last_true(); }
 
  160     size_type card(
void)
 const { 
return ind.card(); }
 
  162     tas_iterator tas_begin(
void)
 
  163     { 
return tas_iterator(*
this, ind, ind_first()); }
 
  164     const_tas_iterator tas_begin(
void)
 const 
  165     { 
return const_tas_iterator(*
this, ind_first()); }
 
  166     tas_iterator tas_end(
void) { 
return tas_iterator(*
this, ind, size()); }
 
  167     const_tas_iterator tas_end(
void)
 const 
  168     { 
return const_tas_iterator(*
this, size()); }
 
  170     const bit_vector &index(
void)
 const { 
return ind; }
 
  171     bool index_valid(
size_type i)
 const { 
return ind[i]; }
 
  172     bool empty(
void)
 const { 
return (ind.card() == 0); }
 
  177     { 
size_type n=ind.first_false(); ind[n]=
true; (*this)[n]=e;  
return n; }
 
  178     void add_to_index(
size_type i, 
const T &e) { ind[i]=
true; (*this)[i]=e; }
 
  179     void sup(
size_type n) { ind[n] = 
false; }
 
  183   template<
class T, 
unsigned char pks>
 
  185     bool ti = ind[i], tj = ind[j]; ind.swap(i,j);
 
  186     if (!ti &&  tj) (*this)[i] = (*this)[j];
 
  187     if (ti  && !tj) (*this)[j] = (*this)[i];
 
  188     if (ti  &&  tj) std::swap((*
this)[i], (*
this)[j]);
 
  191   template<
class T, 
unsigned char pks>
 
  192     void dynamic_tas<T, pks>::compact(
void) {
 
  194       while (ind.last_true() >= ind.card())
 
  195         swap(ind.first_false(), ind.last_true());
 
size_type memsize(void) const
Gives the total memory occupied by the array.
void clear(void)
Clear and desallocate all the elements.
Provide a dynamic bit container.
void clear(L &l)
clear (fill with zeros) a vector or matrix.
void add(const L1 &l1, L2 &l2)
*/
rational_fraction< T > operator-(const polynomial< T > &P, const rational_fraction< T > &Q)
Subtract Q from P.
size_t size_type
used as the common size type in the library