DATAKIT API  V2025.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...
 
 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 ()
 Swap two elements. 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)
 Sorts the array. More...
 
 ~Dtk_tab ()
 

Friends

std::ostream & operator<< (std::ostream &o, const Dtk_tab &d)
 

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
216  {
217  nb=0;
218  rsv=0;
219  v=NULL;
220  }

◆ Dtk_tab() [2/4]

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

◆ ~Dtk_tab()

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

◆ Dtk_tab() [3/4]

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

◆ Dtk_tab() [4/4]

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

Move constructor.

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

Member Function Documentation

◆ at() [1/2]

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

◆ at() [2/2]

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

◆ 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
538  {
539  Pdtk_Assert(nb!=0);
540  return v[nb - 1];
541  }

◆ 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
553  {
554  Pdtk_Assert(nb!=0);
555  return v[nb - 1];
556  }

◆ begin() [1/2]

template<typename T >
iterator Dtk_tab< T >::begin ( )
888  {
889  return v;
890  }

◆ begin() [2/2]

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

◆ 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
523  {
524  return rsv;
525  }

◆ cbegin()

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

◆ cend()

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

◆ 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.
352  {
353  if (v==NULL)
354  return;
355  if (no_delete)
356  {
357  nb=0;
358  return;
359  }
360  delete [] v;
361  nb=0;
362  rsv=0;
363  v=NULL;
364  }

◆ end() [1/2]

template<typename T >
iterator Dtk_tab< T >::end ( )
900  {
901  return v + nb;
902  }

◆ end() [2/2]

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

◆ find() [1/2]

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

◆ find() [2/2]

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

◆ 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
568  {
569  Pdtk_Assert(nb!=0);
570  return v[0];
571  }

◆ 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
583  {
584  Pdtk_Assert(nb!=0);
585  return v[0];
586  }

◆ 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.
244  {
245  return this->v;
246  }

◆ GetSize()

template<typename T >
Dtk_Size_t Dtk_tab< T >::GetSize ( ) const
872  {
873  return 2*sizeof(Dtk_Size_t) + sizeof(T*) + rsv * sizeof(T);
874  }

◆ max_element()

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

◆ max_ithelement()

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

◆ min_element()

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

◆ min_ithelement()

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

◆ operator+=() [1/2]

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

◆ operator+=() [2/2]

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

◆ operator<()

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

◆ operator=() [1/2]

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

◆ 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
307  {
308  if(this != &t)
309  {
310  delete [] v;
311  v = t.v;
312  nb = t.nb;
313  rsv = t.rsv;
314  t.v = 0;
315  t.nb = 0;
316  t.rsv = 0;
317  }
318 
319  return *this;
320  }

◆ operator==()

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

◆ 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 :(
381  {
382 #ifdef _DEBUG_DTK
383  if (k>=nb)
385 #endif
386  return v[k];
387  }

◆ operator[]() [2/2]

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

◆ 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}...
486  {
487  Pdtk_Assert(nb!=0);
488  if( nb == 0 ) { Dtk_ThrowOverflowException(); }
489  nb--;
490  } // 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}...
416  {
417  if (nb==rsv)
418  {
419  if (nb==0)
420  {
421  rsv=1;
422  v = new T[1];
423  v[nb++]=x;
424  }
425  else
426  {
427  rsv*=2;
428  T to_add;
429  to_add = x;
430  T* ex = _dtk_doublerealloc(rsv);
431  //v[nb++]=x;
432  v[ nb++ ] = to_add;
433  delete [] ex;
434  }
435  }
436  else
437  v[nb++]=x;
438  }

◆ 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}...
453  {
454  if (nb==rsv)
455  {
456  if (nb==0)
457  {
458  rsv=1;
459  v = new T[1];
460  v[nb++]=std::move(x);
461  }
462  else
463  {
464  rsv*=2;
465  T* ex = _dtk_doublerealloc(rsv);
466  v[nb++]= std::move(x);
467  delete [] ex;
468  }
469  }
470  else
471  v[nb++]=std::move(x);
472  }

◆ reduce()

template<typename T >
void Dtk_tab< T >::reduce ( )
876  {
877  if (rsv>nb)
878  {
879  rsv = nb;
880  if (rsv==0)
881  rsv = 1;
882  delete [] _dtk_doublerealloc(rsv);
883  }
884  }

◆ 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}
691  {
692  int pos = find( a );
693  if( pos >= 0)
694  {
695  swap( pos, nb - 1 );
696  pop_back();
697  }
698  }

◆ reserve()

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

◆ resize() [1/2]

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

◆ 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}
604  {
605  if (n<=nb)
606  {
607  nb=n;
608  return;
609  }
610  if (n<=0)
611  {
612  clear();
613  return;
614  }
615  if (v==NULL)
616  {
617  Pdtk_Assert(rsv==0 && n>0);
618  v = new T[n];
619  }
620  else
621  delete [] _dtk_doublerealloc(n);
622  for(Dtk_Size_t i=nb;i<n;i++)
623  v[i]=t;
624  nb=rsv=n;
625  }

◆ reverse()

template<typename T >
void Dtk_tab< T >::reverse ( )
885 {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
503  {
504  return nb;
505  }

◆ sort() [1/2]

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

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(tab[0],tab[1]);
//tab is {2,0,1}
712  {
713  sort(Dtk_less<T>());
714  }

◆ 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}
732  {
733  if(nb > 0 )
734  {
735  //_quicksort((int)0,(int)(nb-1),C);
736  T* tmp = new T[nb];
737  _mergesort(tmp,(int)0,(int)(nb-1),C);
738  delete [] tmp;
739  }
740  }

◆ subtab()

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

◆ swap()

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

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}
666  {
667 #ifdef _DEBUG_DTK
668  if ( inA >= nb || inB >= nb )
670 #endif
671  const T Tmp = v[ inA ];
672  v[ inA ] = v[ inB ];
673  v[ inB ] = Tmp;
674  }

Friends And Related Function Documentation

◆ operator<<

template<typename T >
std::ostream& operator<< ( std::ostream &  o,
const Dtk_tab< T > &  d 
)
friend
861  {
862  o<<"<Tab><Size>"<<d.size()<<"</Size>"<<std::endl;
863  Dtk_Size_t i;
864  for(i=0;i<d.size();i++)
865  {
866  o<<"<Elem_"<<i<<">"<< d[i] <<"</Elem_"<<i<<">"<<std::endl;
867  }
868  o << "</Tab>"<<std::endl;
869  return o;
870  }
Dtk_greater
Functor comparison object.
Definition: util_stl_dtk.hpp:27
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:522
Dtk_tab::pop_back
void pop_back()
Removes the last element.
Definition: util_stl_dtk.hpp:485
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:712
Dtk_tab::sort
void sort()
Swap two elements.
Definition: util_stl_dtk.hpp:711
Dtk_less
Functor comparison object.
Definition: util_stl_dtk.hpp:41
Dtk_tab::back
T & back()
Return the elements at the end of the array.
Definition: util_stl_dtk.hpp:537
Dtk_tab::remove
void remove(const T &a)
Removes the first element with the value a.
Definition: util_stl_dtk.hpp:690
Dtk_tab::operator[]
T & operator[](Dtk_Size_t k)
Accesses the ith element - like a classic array -.
Definition: util_stl_dtk.hpp:380
Dtk_tab::find
int find(const T &e) const
Definition: util_stl_dtk.hpp:742
Pdtk_Assert
#define Pdtk_Assert(X)
Definition: define.h:742
Dtk_tab::front
T & front()
Return the elements at the beginning of the array.
Definition: util_stl_dtk.hpp:567
Dtk_tab::resize
void resize(Dtk_Size_t n, const T &t)
Resizes the array.
Definition: util_stl_dtk.hpp:603
Dtk_tab::reserve
void reserve(Dtk_Size_t n)
Definition: util_stl_dtk.hpp:797
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:502
Dtk_tab::swap
void swap(const Dtk_Size_t inA, const Dtk_Size_t inB)
Sorts the array.
Definition: util_stl_dtk.hpp:665
Dtk_swap
void Dtk_swap(T &a, T &b)
Swap any type of data.
Definition: util_stl_dtk.hpp:71
Dtk_tab::push_back
void push_back(const T &x)
Inserts an element at the end of the array.
Definition: util_stl_dtk.hpp:415
Dtk_tab::clear
void clear(int no_delete=0)
Resets the Dtk_tab content.
Definition: util_stl_dtk.hpp:351