DATAKIT SDK  V2026.1
Dtk_tab< T > Class Template Reference

This is a high level array class. More...

Public Types

typedef const_pointer const_iterator
 
typedef T const * const_pointer
 
typedef pointer iterator
 
typedef T * pointer
 
typedef T value_type
 

Public Member Functions

T & at (Dtk_Size_t k)
 
const T & at (Dtk_Size_t k) const
 
T & back ()
 Return the elements at the end of the array. More...
 
const T & back () const
 Return the elements at the end of the array. More...
 
iterator begin ()
 
const_iterator begin () const
 
Dtk_Size_t capacity () const
 Returns the size of the storage space currently allocated for the array, expressed in terms of elements. More...
 
const_iterator cbegin () const
 
const_iterator cend () const
 
void clear (int no_delete=0)
 Resets the Dtk_tab content. More...
 
T * data ()
 
T const * data () const
 
 Dtk_tab ()
 Default constructor. More...
 
 Dtk_tab (const Dtk_tab< T > &t)
 
 Dtk_tab (Dtk_Size_t initreservesize, int resize=0)
 
 Dtk_tab (Dtk_tab< T > &&t) DTK_NOEXCEPT
 Move constructor. More...
 
iterator end ()
 
const_iterator end () const
 
int find (const T &e) const
 
template<typename comp >
int find (const T &e, const comp &C) const
 
T & front ()
 Return the elements at the beginning of the array. More...
 
const T & front () const
 Return the elements at the beginning of the array. More...
 
const T * GetArray () const
 Returns array of T elements. More...
 
Dtk_Size_t GetSize () const
 
max_element () const
 
Dtk_Size_t max_ithelement ()
 
min_element () const
 
Dtk_Size_t min_ithelement ()
 
Dtk_taboperator+= (const Dtk_tab &t)
 
Dtk_taboperator+= (Dtk_tab &&t)
 
int operator< (const Dtk_tab< T > &t) const
 
Dtk_taboperator= (const Dtk_tab< T > &t)
 
Dtk_tab< T > & operator= (Dtk_tab< T > &&t) DTK_NOEXCEPT
 Move assignment operator. More...
 
int operator== (const Dtk_tab< T > &t) const
 
T & operator[] (Dtk_Size_t k)
 Accesses the ith element - like a classic array -. More...
 
const T & operator[] (Dtk_Size_t k) const
 
void pop_back ()
 Removes the last element. More...
 
void push_back (const T &x)
 Inserts an element at the end of the array. More...
 
void push_back (T &&x)
 Inserts an element by moving it at the end of the array. More...
 
void reduce ()
 
void remove (const T &a)
 Removes the first element with the value a. More...
 
void reserve (Dtk_Size_t n)
 
void resize (Dtk_Size_t n)
 
void resize (Dtk_Size_t n, const T &t)
 Resizes the array. More...
 
void reverse ()
 
Dtk_Size_t size () const
 Returns the size of the array. More...
 
void sort ()
 Sorts the array. More...
 
template<typename comp >
void sort (const comp &C)
 Sorts the array with custom sorting. More...
 
Dtk_tab subtab (Dtk_Size_t a, Dtk_Size_t b)
 
void swap (const Dtk_Size_t inA, const Dtk_Size_t inB)
 Swap two elements. More...
 
 ~Dtk_tab ()
 

Detailed Description

template<typename T>
class Dtk_tab< T >

This is a high level array class.

This class lets you use optimized arrays.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef const_pointer Dtk_tab< T >::const_iterator

◆ const_pointer

template<typename T >
typedef T const* Dtk_tab< T >::const_pointer

◆ iterator

template<typename T >
typedef pointer Dtk_tab< T >::iterator

◆ pointer

template<typename T >
typedef T* Dtk_tab< T >::pointer

◆ value_type

template<typename T >
typedef T Dtk_tab< T >::value_type

Constructor & Destructor Documentation

◆ Dtk_tab() [1/4]

template<typename T >
Dtk_tab< T >::Dtk_tab ( )

Default constructor.

Remarks
create an empty array
215  {
216  nb=0;
217  rsv=0;
218  v=NULL;
219  }

◆ Dtk_tab() [2/4]

template<typename T >
Dtk_tab< T >::Dtk_tab ( Dtk_Size_t  initreservesize,
int  resize = 0 
)
221  {
222  Pdtk_Assert(initreservesize>0); // forbidden : at least one element on reserve.
223  rsv=initreservesize;
224  nb=0;
225  if (resize)
226  nb = rsv;
227  if (rsv>0)
228  v=new T[rsv];
229  else
230  v=NULL;
231  }

◆ ~Dtk_tab()

template<typename T >
Dtk_tab< T >::~Dtk_tab ( )
233  {
234  if (v!=NULL)
235  {
236  delete [] v;
237  v=NULL;
238  }
239  }

◆ Dtk_tab() [3/4]

template<typename T >
Dtk_tab< T >::Dtk_tab ( const Dtk_tab< T > &  t)
249  {
250 //#ifdef DTK_DEBUG_STL_TRACE
251 // FILE* F = fopen("/stltrace.txt","a");
252 // fprintf(F,"Dtk_tab copy constructor size : %d ; elemsize : %d\n",t.size(),sizeof(T));
253 // fclose(F);
254 //#endif
255  nb=t.nb;
256  rsv=t.nb; // shrink_to_fit while copy
257  if (rsv>0)
258  {
259  Pdtk_Assert(nb > 0);
260  v=new T[nb];
261  for(Dtk_Size_t i=0;i<nb;i++)
262  v[i] = t.v[i];
263  }
264  else
265  v=NULL;
266  }

◆ Dtk_tab() [4/4]

template<typename T >
Dtk_tab< T >::Dtk_tab ( Dtk_tab< T > &&  t)

Move constructor.

Parameters
tthe Dtk_tab to move
298  : v(t.v), nb(t.nb), rsv(t.rsv)
299  {
300  t.v = 0;
301  t.nb = 0;
302  t.rsv = 0;
303  }

Member Function Documentation

◆ at() [1/2]

template<typename T >
T& Dtk_tab< T >::at ( Dtk_Size_t  k)
398  {
399  return operator[](k);
400  }

◆ at() [2/2]

template<typename T >
const T& Dtk_tab< T >::at ( Dtk_Size_t  k) const
402  {
403  return operator[](k);
404  }

◆ back() [1/2]

template<typename T >
T& Dtk_tab< T >::back ( )

Return the elements at the end of the array.

Sample:

Dtk_tab<int> L; //we construct an array of int.
L.push_back(5);
L.push_back(35);
L.push_back(8); // array is now : 5 - 35 - 8
int a = L.back(); // a is 8
539  {
540  Pdtk_Assert(nb!=0);
541  return v[nb - 1];
542  }

◆ back() [2/2]

template<typename T >
const T& Dtk_tab< T >::back ( ) const

Return the elements at the end of the array.

Sample:

Dtk_tab<int> L; //we construct an array of int.
L.push_back(5);
L.push_back(35);
L.push_back(8); // array is now : 5 - 35 - 8
int a = L.back(); // a is 8
554  {
555  Pdtk_Assert(nb!=0);
556  return v[nb - 1];
557  }

◆ begin() [1/2]

template<typename T >
iterator Dtk_tab< T >::begin ( )
892  {
893  return v;
894  }

◆ begin() [2/2]

template<typename T >
const_iterator Dtk_tab< T >::begin ( ) const
896  {
897  return v;
898  }

◆ capacity()

template<typename T >
Dtk_Size_t Dtk_tab< T >::capacity ( ) const

Returns the size of the storage space currently allocated for the array, expressed in terms of elements.

This capacity is not necessarily equal to the size. It can be equal or greater. The capacity of the Dtk_tab can be explicitly altered by calling member Dtk_tab::reserve.

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.reserve(5); //we reserve 5 element of type int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
Dtk_Size_t size = tab.size(); //size is equal to 3
Dtk_Size_t capacity = tab.capacity(); //capacity is equal to 5
524  {
525  return rsv;
526  }

◆ cbegin()

template<typename T >
const_iterator Dtk_tab< T >::cbegin ( ) const
900  {
901  return v;
902  }

◆ cend()

template<typename T >
const_iterator Dtk_tab< T >::cend ( ) const
912  {
913  return v + nb;
914  }

◆ clear()

template<typename T >
void Dtk_tab< T >::clear ( int  no_delete = 0)

Resets the Dtk_tab content.

Remarks
If the Dtk_tab has pointers, theses ones aren't deleted.

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
Now tab has 3 elements...
tab.clear(); //Now tab hasn't any element.
353  {
354  if (v==NULL)
355  return;
356  if (no_delete)
357  {
358  nb=0;
359  return;
360  }
361  delete [] v;
362  nb=0;
363  rsv=0;
364  v=NULL;
365  }

◆ data() [1/2]

template<typename T >
T* Dtk_tab< T >::data ( )
246 { return v; }

◆ data() [2/2]

template<typename T >
T const* Dtk_tab< T >::data ( ) const
247 { return v; }

◆ end() [1/2]

template<typename T >
iterator Dtk_tab< T >::end ( )
904  {
905  return v + nb;
906  }

◆ end() [2/2]

template<typename T >
const_iterator Dtk_tab< T >::end ( ) const
908  {
909  return v + nb;
910  }

◆ find() [1/2]

template<typename T >
int Dtk_tab< T >::find ( const T &  e) const
747  {
748  for(Dtk_Size_t i=0;i<nb;i++)
749  if (v[i]==e)
750  return (int)i;
751  return -1;
752  }

◆ find() [2/2]

template<typename T >
template<typename comp >
int Dtk_tab< T >::find ( const T &  e,
const comp &  C 
) const
755  {
756  for(Dtk_Size_t i=0;i<nb;i++)
757  if (!C(v[i],e) && !C(e,v[i]))
758  return (int)i;
759  return -1;
760  }

◆ front() [1/2]

template<typename T >
T& Dtk_tab< T >::front ( )

Return the elements at the beginning of the array.

Sample:

Dtk_tab<int> L; //we construct a list of array.
L.push_back(5);
L.push_back(35);
L.push_back(8); // array is now : 5 - 35 - 8
int a = L.front(); // a is 5
569  {
570  Pdtk_Assert(nb!=0);
571  return v[0];
572  }

◆ front() [2/2]

template<typename T >
const T& Dtk_tab< T >::front ( ) const

Return the elements at the beginning of the array.

Sample:

Dtk_tab<int> L; //we construct a list of array.
L.push_back(5);
L.push_back(35);
L.push_back(8); // array is now : 5 - 35 - 8
int a = L.front(); // a is 5
584  {
585  Pdtk_Assert(nb!=0);
586  return v[0];
587  }

◆ GetArray()

template<typename T >
const T* Dtk_tab< T >::GetArray ( ) const

Returns array of T elements.

Remarks
You should call size () method to know returned array size.
243  {
244  return this->v;
245  }

◆ GetSize()

template<typename T >
Dtk_Size_t Dtk_tab< T >::GetSize ( ) const
876  {
877  return 2*sizeof(Dtk_Size_t) + sizeof(T*) + rsv * sizeof(T);
878  }

◆ max_element()

template<typename T >
T Dtk_tab< T >::max_element ( ) const
826  {
827  if (nb==0)
828  return T();
829  T max = v[0];
830  for(Dtk_Size_t i=0;i<nb;i++)
831  if (v[i]>max)
832  max=v[i];
833  return max;
834  }

◆ max_ithelement()

template<typename T >
Dtk_Size_t Dtk_tab< T >::max_ithelement ( )
850  {
851  if (nb==0)
852  return 0;
853  Dtk_Size_t imax = 0;
854  T max = v[0];
855  for(Dtk_Size_t i=0;i<nb;i++)
856  if (v[i]>max)
857  {
858  max=v[i];
859  imax = i;
860  }
861  return imax;
862  }

◆ min_element()

template<typename T >
T Dtk_tab< T >::min_element ( ) const
816  {
817  if (nb==0)
818  return T();
819  T min = v[0];
820  for(Dtk_Size_t i=0;i<nb;i++)
821  if (v[i]<min)
822  min=v[i];
823  return min;
824  }

◆ min_ithelement()

template<typename T >
Dtk_Size_t Dtk_tab< T >::min_ithelement ( )
836  {
837  if (nb==0)
838  return 0;
839  Dtk_Size_t imin = 0;
840  T min = v[0];
841  for(Dtk_Size_t i=0;i<nb;i++)
842  if (v[i]<min)
843  {
844  min=v[i];
845  imin = i;
846  }
847  return imin;
848  }

◆ operator+=() [1/2]

template<typename T >
Dtk_tab& Dtk_tab< T >::operator+= ( const Dtk_tab< T > &  t)
763  {
764  if (t.nb==0) // empty 2nd
765  return *this;
766  rsv=nb+t.nb;
767  if (v==NULL)
768  v = new T[rsv];
769  else
770  delete [] _dtk_doublerealloc(rsv);
771  for(Dtk_Size_t i=0;i<t.nb;i++)
772  v[i+nb] = t.v[i];
773  nb=nb+t.nb;
774  return *this;
775  }

◆ operator+=() [2/2]

template<typename T >
Dtk_tab& Dtk_tab< T >::operator+= ( Dtk_tab< T > &&  t)
778  {
779  if( t.nb == 0 )
780  return *this;
781  rsv = nb + t.nb;
782  if( v == nullptr )
783  v = new T[ rsv ];
784  else
785  delete[] _dtk_doublerealloc( rsv );
786  for( Dtk_Size_t i = 0; i < t.nb; i++ )
787  v[ i + nb ] = std::move( t.v[ i ] );
788  nb = nb + t.nb;
789  return *this;
790  }

◆ operator<()

template<typename T >
int Dtk_tab< T >::operator< ( const Dtk_tab< T > &  t) const
325  {
326  Dtk_Size_t i;
327  if (size()<t.size())
328  return 1;
329  if (t.size()<size())
330  return 0;
331  for(i=0;i<size();i++)
332  {
333  if ((v[i]<t.v[i]))
334  return 1;
335  if ((t.v[i]<v[i]))
336  return 0;
337  }
338  return 0;
339  }

◆ operator=() [1/2]

template<typename T >
Dtk_tab& Dtk_tab< T >::operator= ( const Dtk_tab< T > &  t)
268  {
269  if (&t!=this)
270  {
271  if (v!=NULL)
272  {
273  Pdtk_Assert(rsv>0);
274  delete [] v;
275  }
276  v=NULL;
277  nb=t.nb;
278  rsv=t.nb;
279  if (t.v!=NULL && nb > 0)
280  {
281  v=new T[nb];
282  for(Dtk_Size_t i=0;i<nb;i++)
283  v[i] = t.v[i];
284  }
285  }
286  return *this;
287  }

◆ operator=() [2/2]

template<typename T >
Dtk_tab<T>& Dtk_tab< T >::operator= ( Dtk_tab< T > &&  t)

Move assignment operator.

Parameters
tthe Dtk_tab to move
308  {
309  if(this != &t)
310  {
311  delete [] v;
312  v = t.v;
313  nb = t.nb;
314  rsv = t.rsv;
315  t.v = 0;
316  t.nb = 0;
317  t.rsv = 0;
318  }
319 
320  return *this;
321  }

◆ operator==()

template<typename T >
int Dtk_tab< T >::operator== ( const Dtk_tab< T > &  t) const
289  {
290  if (t<*this || *this<t)
291  return 0;
292  return 1;
293  }

◆ operator[]() [1/2]

template<typename T >
T& Dtk_tab< T >::operator[] ( Dtk_Size_t  k)

Accesses the ith element - like a classic array -.

Parameters
[in]k: The element position.
Warning
There isn't any check for the element position validity !!!

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
// tab is {0,2,1}
int elt = tab[2]; //elt is equal to 1
tab[1] = 5; // tab is {0,5,1}
tab[5] = 5; // Error !!! The program will crash :(
382  {
383 #ifdef _DEBUG_DTK
384  if (k>=nb)
386 #endif
387  return v[k];
388  }

◆ operator[]() [2/2]

template<typename T >
const T& Dtk_tab< T >::operator[] ( Dtk_Size_t  k) const
390  {
391 #ifdef _DEBUG_DTK
392  if (k>=nb)
394 #endif
395  return v[k];
396  }

◆ pop_back()

template<typename T >
void Dtk_tab< T >::pop_back ( )

Removes the last element.

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
Now tab is {0,2,1}...
487  {
488  Pdtk_Assert(nb!=0);
489  if( nb == 0 ) { Dtk_ThrowOverflowException(); }
490  nb--;
491  } // extent : liberation a 1/3.

◆ push_back() [1/2]

template<typename T >
void Dtk_tab< T >::push_back ( const T &  x)

Inserts an element at the end of the array.

Parameters
[in]xThe element to insert.

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
Now tab is {0,2,1}...
417  {
418  if (nb==rsv)
419  {
420  if (nb==0)
421  {
422  rsv=1;
423  v = new T[1];
424  v[nb++]=x;
425  }
426  else
427  {
428  rsv*=2;
429  T to_add;
430  to_add = x;
431  T* ex = _dtk_doublerealloc(rsv);
432  //v[nb++]=x;
433  v[ nb++ ] = to_add;
434  delete [] ex;
435  }
436  }
437  else
438  v[nb++]=x;
439  }

◆ push_back() [2/2]

template<typename T >
void Dtk_tab< T >::push_back ( T &&  x)

Inserts an element by moving it at the end of the array.

Parameters
[in]xThe element to insert.

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
Now tab is {0,2,1}...
454  {
455  if (nb==rsv)
456  {
457  if (nb==0)
458  {
459  rsv=1;
460  v = new T[1];
461  v[nb++]=std::move(x);
462  }
463  else
464  {
465  rsv*=2;
466  T* ex = _dtk_doublerealloc(rsv);
467  v[nb++]= std::move(x);
468  delete [] ex;
469  }
470  }
471  else
472  v[nb++]=std::move(x);
473  }

◆ reduce()

template<typename T >
void Dtk_tab< T >::reduce ( )
880  {
881  if (rsv>nb)
882  {
883  rsv = nb;
884  if (rsv==0)
885  rsv = 1;
886  delete [] _dtk_doublerealloc(rsv);
887  }
888  }

◆ remove()

template<typename T >
void Dtk_tab< T >::remove ( const T &  a)

Removes the first element with the value a.

Parameters
[in]aThe value of the element that should be removed
Remarks
: The order of the elements of the tab won't be conserved, the last element is moved to the old position of the removed element

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(1); //we insert '1'
tab.push_back(2); //we insert '2'
tab.push_back(3); //we insert '3'
tab.remove(1); //Now tab is {0,3,2}
tab.remove(2); //Now tab is {0,3}
693  {
694  int pos = find( a );
695  if( pos >= 0)
696  {
697  swap( pos, nb - 1 );
698  pop_back();
699  }
700  }

◆ reserve()

template<typename T >
void Dtk_tab< T >::reserve ( Dtk_Size_t  n)
802  {
803  if (n<=rsv)
804  return;
805  if (v==NULL)
806  {
807  Pdtk_Assert(rsv==0);
808  v = new T[n];
809  rsv = n;
810  return;
811  }
812  rsv = n;
813  delete [] _dtk_doublerealloc(rsv);
814  }

◆ resize() [1/2]

template<typename T >
void Dtk_tab< T >::resize ( Dtk_Size_t  n)
628  {
629  if (n<=nb)
630  {
631  nb=n;
632  return;
633  }
634  if (n<=0)
635  {
636  clear();
637  return;
638  }
639  if (n<rsv) // cas ou n>nb && n<rsv
640  {
641  nb = n;
642  return;
643  }
644  if (v==NULL)
645  {
646  Pdtk_Assert(rsv==0);
647  v = new T[n];
648  }
649  else
650  delete [] _dtk_doublerealloc(n);
651 
652  nb=rsv=n;
653  }

◆ resize() [2/2]

template<typename T >
void Dtk_tab< T >::resize ( Dtk_Size_t  n,
const T &  t 
)

Resizes the array.

Parameters
[in]nThe new size.
[in]tThe filling element.
Remarks
If the new size is lower than the old one, the last elements are removed.
If the new size is greater than the old one, inserts t in the new elements.

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
tab.resize(2); //Now tab is {0,2}
tab.resize(5,6); //Now tab is {0,2,6,6,6}
605  {
606  if (n<=nb)
607  {
608  nb=n;
609  return;
610  }
611  if (n<=0)
612  {
613  clear();
614  return;
615  }
616  if (v==NULL)
617  {
618  Pdtk_Assert(rsv==0 && n>0);
619  v = new T[n];
620  }
621  else
622  delete [] _dtk_doublerealloc(n);
623  for(Dtk_Size_t i=nb;i<n;i++)
624  v[i]=t;
625  nb=rsv=n;
626  }

◆ reverse()

template<typename T >
void Dtk_tab< T >::reverse ( )
889 {Dtk_Size_t i;for(i=0;i<nb/2;i++) Dtk_swap(v[i],v[nb-i-1]);}

◆ size()

template<typename T >
Dtk_Size_t Dtk_tab< T >::size ( ) const

Returns the size of the array.

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
int size = tab.size(); //size is equal to 3
504  {
505  return nb;
506  }

◆ sort() [1/2]

template<typename T >
void Dtk_tab< T >::sort ( )

Sorts the array.

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
//tab is {0,2,1}
tab.sort();
//tab is {0,1,2}
716  {
717  sort(Dtk_less<T>());
718  }

◆ sort() [2/2]

template<typename T >
template<typename comp >
void Dtk_tab< T >::sort ( const comp &  C)

Sorts the array with custom sorting.

Parameters
[in]CComparison Functor
Remarks
Comparison functor need to be instanciated with default : use (). See sample.
Use a custom functor or one of the two internal functors available : Dtk_less (default) and Dtk_greater

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
//tab is {0,2,1}
//tab is {2,1,0}
736  {
737  if(nb > 0 )
738  {
739  //_quicksort((int)0,(int)(nb-1),C);
740  T* tmp = new T[nb];
741  _mergesort(tmp,(int)0,(int)(nb-1),C);
742  delete [] tmp;
743  }
744  }

◆ subtab()

template<typename T >
Dtk_tab Dtk_tab< T >::subtab ( Dtk_Size_t  a,
Dtk_Size_t  b 
)
793  {
794  Pdtk_Assert(a<nb && b<nb && b>=a);
795  Dtk_tab<T> res;
796  res.resize(b-a+1);
797  for(Dtk_Size_t i=0;i<res.rsv;i++)
798  res.v[i] = v[a+i];
799  return res;
800  }

◆ swap()

template<typename T >
void Dtk_tab< T >::swap ( const Dtk_Size_t  inA,
const Dtk_Size_t  inB 
)

Swap two elements.

Sample:

Dtk_tab<int> tab; //we construct an array of int.
tab.push_back(0); //we insert '0'
tab.push_back(2); //we insert '2'
tab.push_back(1); //we insert '1'
//tab is {0,2,1}
tab.swap( 0, 1 );
//tab is {2,0,1}
668  {
669 #ifdef _DEBUG_DTK
670  if ( inA >= nb || inB >= nb )
672 #endif
673  const T Tmp = v[ inA ];
674  v[ inA ] = v[ inB ];
675  v[ inB ] = Tmp;
676  }
Dtk_greater
Functor comparison object.
Definition: util_stl_dtk.hpp:26
Dtk_tab::capacity
Dtk_Size_t capacity() const
Returns the size of the storage space currently allocated for the array, expressed in terms of elemen...
Definition: util_stl_dtk.hpp:523
Dtk_tab::pop_back
void pop_back()
Removes the last element.
Definition: util_stl_dtk.hpp:486
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:715
Dtk_tab::sort
void sort()
Sorts the array.
Definition: util_stl_dtk.hpp:715
Dtk_less
Functor comparison object.
Definition: util_stl_dtk.hpp:40
Dtk_tab::back
T & back()
Return the elements at the end of the array.
Definition: util_stl_dtk.hpp:538
Dtk_tab::remove
void remove(const T &a)
Removes the first element with the value a.
Definition: util_stl_dtk.hpp:692
Dtk_tab::operator[]
T & operator[](Dtk_Size_t k)
Accesses the ith element - like a classic array -.
Definition: util_stl_dtk.hpp:381
Dtk_tab::find
int find(const T &e) const
Definition: util_stl_dtk.hpp:746
Pdtk_Assert
#define Pdtk_Assert(X)
Definition: define.h:746
Dtk_tab::front
T & front()
Return the elements at the beginning of the array.
Definition: util_stl_dtk.hpp:568
Dtk_tab::resize
void resize(Dtk_Size_t n, const T &t)
Resizes the array.
Definition: util_stl_dtk.hpp:604
Dtk_tab::reserve
void reserve(Dtk_Size_t n)
Definition: util_stl_dtk.hpp:801
Dtk_ThrowOverflowException
void Dtk_ThrowOverflowException()
Dtk_tab< int >
Dtk_tab::size
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:503
Dtk_tab::swap
void swap(const Dtk_Size_t inA, const Dtk_Size_t inB)
Swap two elements.
Definition: util_stl_dtk.hpp:667
Dtk_swap
void Dtk_swap(T &a, T &b)
Swap any type of data.
Definition: util_stl_dtk.hpp:70
Dtk_tab::push_back
void push_back(const T &x)
Inserts an element at the end of the array.
Definition: util_stl_dtk.hpp:416
Dtk_tab::clear
void clear(int no_delete=0)
Resets the Dtk_tab content.
Definition: util_stl_dtk.hpp:352