![Logo](tetiere_ht.jpg) |
DATAKIT API
V2025.1
|
|
This is a high level array class.
More...
template<typename T>
class Dtk_tab< T >
This is a high level array class.
This class lets you use optimized arrays.
◆ const_iterator
◆ const_pointer
◆ iterator
◆ pointer
◆ value_type
◆ Dtk_tab() [1/4]
◆ Dtk_tab() [2/4]
◆ ~Dtk_tab()
◆ Dtk_tab() [3/4]
◆ Dtk_tab() [4/4]
Move constructor.
- Parameters
-
297 : v(t.v), nb(t.nb), rsv(t.rsv)
◆ at() [1/2]
◆ at() [2/2]
◆ back() [1/2]
Return the elements at the end of the array.
Sample:
◆ back() [2/2]
template<typename T >
const T& Dtk_tab< T >::back |
( |
| ) |
const |
Return the elements at the end of the array.
Sample:
◆ begin() [1/2]
◆ begin() [2/2]
◆ capacity()
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:
◆ cbegin()
◆ cend()
◆ clear()
template<typename T >
void Dtk_tab< T >::clear |
( |
int |
no_delete = 0 | ) |
|
Resets the Dtk_tab content.
Sample:
Now tab has 3 elements...
◆ end() [1/2]
◆ end() [2/2]
◆ find() [1/2]
template<typename T >
int Dtk_tab< T >::find |
( |
const T & |
e | ) |
const |
◆ find() [2/2]
template<typename T >
template<typename comp >
int Dtk_tab< T >::find |
( |
const T & |
e, |
|
|
const comp & |
C |
|
) |
| const |
753 if (!C(v[i],e) && !C(e,v[i]))
◆ front() [1/2]
Return the elements at the beginning of the array.
Sample:
◆ front() [2/2]
template<typename T >
const T& Dtk_tab< T >::front |
( |
| ) |
const |
Return the elements at the beginning of the array.
Sample:
◆ GetArray()
template<typename T >
const T* Dtk_tab< T >::GetArray |
( |
| ) |
const |
Returns array of T elements.
◆ GetSize()
873 return 2*
sizeof(
Dtk_Size_t) +
sizeof(T*) + rsv *
sizeof(T);
◆ max_element()
template<typename T >
T Dtk_tab< T >::max_element |
( |
| ) |
const |
◆ max_ithelement()
◆ min_element()
template<typename T >
T Dtk_tab< T >::min_element |
( |
| ) |
const |
◆ min_ithelement()
◆ operator+=() [1/2]
766 delete [] _dtk_doublerealloc(rsv);
◆ operator+=() [2/2]
781 delete[] _dtk_doublerealloc( rsv );
783 v[ i + nb ] = std::move( t.v[ i ] );
◆ operator<()
330 for(i=0;i<
size();i++)
◆ operator=() [1/2]
278 if (t.v!=NULL && nb > 0)
◆ operator=() [2/2]
Move assignment operator.
- Parameters
-
◆ operator==()
289 if (t<*
this || *
this<t)
◆ operator[]() [1/2]
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:
int elt = tab[2];
tab[1] = 5;
tab[5] = 5;
◆ operator[]() [2/2]
◆ pop_back()
Removes the last element.
Sample:
◆ 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] | x | The element to insert. |
Sample:
430 T* ex = _dtk_doublerealloc(rsv);
◆ 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] | x | The element to insert. |
Sample:
460 v[nb++]=std::move(x);
465 T* ex = _dtk_doublerealloc(rsv);
466 v[nb++]= std::move(x);
471 v[nb++]=std::move(x);
◆ reduce()
882 delete [] _dtk_doublerealloc(rsv);
◆ remove()
template<typename T >
void Dtk_tab< T >::remove |
( |
const T & |
a | ) |
|
Removes the first element with the value a.
- Parameters
-
[in] | a | The value of the element that should be removed |
Sample:
◆ reserve()
809 delete [] _dtk_doublerealloc(rsv);
◆ resize() [1/2]
649 delete [] _dtk_doublerealloc(n);
◆ resize() [2/2]
Resizes the array.
- Parameters
-
[in] | n | The new size. |
[in] | t | The filling element. |
Sample:
621 delete [] _dtk_doublerealloc(n);
◆ reverse()
◆ size()
Returns the size of the array.
Sample:
◆ sort() [1/2]
Swap two elements.
Sample:
◆ sort() [2/2]
template<typename T >
template<typename comp >
void Dtk_tab< T >::sort |
( |
const comp & |
C | ) |
|
Sorts the array with custom sorting.
- Parameters
-
Sample:
737 _mergesort(tmp,(
int)0,(
int)(nb-1),C);
◆ subtab()
◆ swap()
Sorts the array.
Sample:
668 if ( inA >= nb || inB >= nb )
671 const T Tmp = v[ inA ];
◆ operator<<
template<typename T >
std::ostream& operator<< |
( |
std::ostream & |
o, |
|
|
const Dtk_tab< T > & |
d |
|
) |
| |
|
friend |
862 o<<
"<Tab><Size>"<<d.
size()<<
"</Size>"<<std::endl;
864 for(i=0;i<d.
size();i++)
866 o<<
"<Elem_"<<i<<
">"<< d[i] <<
"</Elem_"<<i<<
">"<<std::endl;
868 o <<
"</Tab>"<<std::endl;
Functor comparison object.
Definition: util_stl_dtk.hpp:27
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
void pop_back()
Removes the last element.
Definition: util_stl_dtk.hpp:485
size_t Dtk_Size_t
Definition: define.h:712
void sort()
Swap two elements.
Definition: util_stl_dtk.hpp:711
Functor comparison object.
Definition: util_stl_dtk.hpp:41
T & back()
Return the elements at the end of the array.
Definition: util_stl_dtk.hpp:537
void remove(const T &a)
Removes the first element with the value a.
Definition: util_stl_dtk.hpp:690
T & operator[](Dtk_Size_t k)
Accesses the ith element - like a classic array -.
Definition: util_stl_dtk.hpp:380
int find(const T &e) const
Definition: util_stl_dtk.hpp:742
#define Pdtk_Assert(X)
Definition: define.h:742
T & front()
Return the elements at the beginning of the array.
Definition: util_stl_dtk.hpp:567
void resize(Dtk_Size_t n, const T &t)
Resizes the array.
Definition: util_stl_dtk.hpp:603
void reserve(Dtk_Size_t n)
Definition: util_stl_dtk.hpp:797
void Dtk_ThrowOverflowException()
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:502
void swap(const Dtk_Size_t inA, const Dtk_Size_t inB)
Sorts the array.
Definition: util_stl_dtk.hpp:665
void Dtk_swap(T &a, T &b)
Swap any type of data.
Definition: util_stl_dtk.hpp:71
void push_back(const T &x)
Inserts an element at the end of the array.
Definition: util_stl_dtk.hpp:415
void clear(int no_delete=0)
Resets the Dtk_tab content.
Definition: util_stl_dtk.hpp:351