 |
DATAKIT API
V2025.2
|
|
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
-
299 : 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...
◆ data() [1/2]
◆ data() [2/2]
template<typename T >
T const* Dtk_tab< T >::data |
( |
| ) |
const |
◆ 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 |
755 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()
875 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]
768 delete [] _dtk_doublerealloc(rsv);
◆ operator+=() [2/2]
783 delete[] _dtk_doublerealloc( rsv );
785 v[ i + nb ] = std::move( t.v[ i ] );
◆ operator<()
332 for(i=0;i<
size();i++)
◆ operator=() [1/2]
280 if (t.v!=NULL && nb > 0)
◆ operator=() [2/2]
Move assignment operator.
- Parameters
-
◆ operator==()
291 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:
432 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:
462 v[nb++]=std::move(x);
467 T* ex = _dtk_doublerealloc(rsv);
468 v[nb++]= std::move(x);
473 v[nb++]=std::move(x);
◆ reduce()
884 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()
811 delete [] _dtk_doublerealloc(rsv);
◆ resize() [1/2]
651 delete [] _dtk_doublerealloc(n);
◆ resize() [2/2]
Resizes the array.
- Parameters
-
[in] | n | The new size. |
[in] | t | The filling element. |
Sample:
623 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:
739 _mergesort(tmp,(
int)0,(
int)(nb-1),C);
◆ subtab()
◆ swap()
Sorts the array.
Sample:
670 if ( inA >= nb || inB >= nb )
673 const T Tmp = v[ inA ];
◆ operator<<
template<typename T >
std::ostream& operator<< |
( |
std::ostream & |
o, |
|
|
const Dtk_tab< T > & |
d |
|
) |
| |
|
friend |
864 o<<
"<Tab><Size>"<<d.
size()<<
"</Size>"<<std::endl;
866 for(i=0;i<d.
size();i++)
868 o<<
"<Elem_"<<i<<
">"<< d[i] <<
"</Elem_"<<i<<
">"<<std::endl;
870 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:524
void pop_back()
Removes the last element.
Definition: util_stl_dtk.hpp:487
size_t Dtk_Size_t
Definition: define.h:712
void sort()
Swap two elements.
Definition: util_stl_dtk.hpp:713
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:539
void remove(const T &a)
Removes the first element with the value a.
Definition: util_stl_dtk.hpp:692
T & operator[](Dtk_Size_t k)
Accesses the ith element - like a classic array -.
Definition: util_stl_dtk.hpp:382
int find(const T &e) const
Definition: util_stl_dtk.hpp:744
#define Pdtk_Assert(X)
Definition: define.h:742
T & front()
Return the elements at the beginning of the array.
Definition: util_stl_dtk.hpp:569
void resize(Dtk_Size_t n, const T &t)
Resizes the array.
Definition: util_stl_dtk.hpp:605
void reserve(Dtk_Size_t n)
Definition: util_stl_dtk.hpp:799
void Dtk_ThrowOverflowException()
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:504
void swap(const Dtk_Size_t inA, const Dtk_Size_t inB)
Sorts the array.
Definition: util_stl_dtk.hpp:667
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:417
void clear(int no_delete=0)
Resets the Dtk_tab content.
Definition: util_stl_dtk.hpp:353