![Logo](tetiere_ht.jpg) |
DATAKIT API
V2025.1
|
|
Go to the documentation of this file. 1 #ifndef UTIL_STL_DTK_HPP_
2 #define UTIL_STL_DTK_HPP_
11 template <
typename T1,
typename T2>
30 int operator()(
const T& t1,
const T& t2)
const {
return t1>t2;}
44 int operator()(
const T& t1,
const T& t2)
const {
return t1<t2;}
73 T tmp = std::move( a );
86 struct allocator_from_t
88 T * operator()( std::pair<T *, Dtk_Size_t> src,
Dtk_Size_t n )
91 #if !defined( _MSC_VER ) || _MSC_VER >= 1700 // at least vs12
92 do_move_if( src.first, src.first + src.second, out, std::integral_constant<
bool, std::is_move_assignable<T>::value>() );
94 do_move_if( src.first, src.first + src.second, out, std::integral_constant<bool, false>() );
99 void do_move_if( T *
begin, T *
end, T * dst, std::true_type )
101 for( ;
begin !=
end; ( void )( ++
begin ), ( void )( ++dst ) )
102 *dst = std::move( *
begin );
104 void do_move_if( T *
begin, T *
end, T * dst, std::false_type )
106 for( ;
begin !=
end; ( void )( ++
begin ), ( void )( ++dst ) )
131 v = allocator_from_t()( std::make_pair( old, nb ), s );
186 template <
typename comp>
187 void _mergesort(T* temp,
int left,
int right,
const comp& C)
189 int i, j, k, mid = (left+right)/2;
190 if (left == right)
return;
191 _mergesort(temp, left, mid,C);
192 _mergesort(temp, mid+1, right,C);
194 for (i=left; i<=mid; i++)
196 for (j=1; j<=right-mid; j++)
197 temp[right-j+1] = v[j+mid];
199 for (i=left,j=right,k=left; k<=right; k++)
200 if (C(temp[i],temp[j]))
278 if (t.v!=NULL && nb > 0)
289 if (t<*
this || *
this<t)
294 #ifndef DTK_NO_CXX11_RVALUE_REFERENCES
330 for(i=0;i<
size();i++)
430 T* ex = _dtk_doublerealloc(rsv);
440 #ifndef DTK_NO_CXX11_RVALUE_REFERENCES
460 v[nb++]=std::move(x);
465 T* ex = _dtk_doublerealloc(rsv);
466 v[nb++]= std::move(x);
471 v[nb++]=std::move(x);
621 delete [] _dtk_doublerealloc(n);
649 delete [] _dtk_doublerealloc(n);
668 if ( inA >= nb || inB >= nb )
671 const T Tmp = v[ inA ];
730 template <
typename comp>
737 _mergesort(tmp,(
int)0,(
int)(nb-1),C);
749 template <
typename comp>
750 int find(
const T& e,
const comp& C)
const
753 if (!C(v[i],e) && !C(e,v[i]))
766 delete [] _dtk_doublerealloc(rsv);
781 delete[] _dtk_doublerealloc( rsv );
783 v[ i + nb ] = std::move( t.v[ i ] );
809 delete [] _dtk_doublerealloc(rsv);
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;
873 return 2*
sizeof(
Dtk_Size_t) +
sizeof(T*) + rsv *
sizeof(T);
882 delete [] _dtk_doublerealloc(rsv);
915 template <
typename T1,
typename T2>
924 template <
typename Arg,
typename Arg2>
Dtk_pair( Arg&& a, Arg2&& b ) :
first( std::forward<Arg>( a ) ),
second( std::forward<Arg2>( b ) )
935 o<<
"<Pair><First>" << d.
first <<
"</First><Second>" << d.
second <<
"</Second></Pair>" <<std::endl;
972 template <
typename T1,
typename T2>
988 template<
class InputIterator,
class Predicate>
989 bool all_of(InputIterator first, InputIterator last, Predicate Pred)
991 for (; first != last; ++first)
1003 template<
typename T,
class Predicate>
1017 template<
class InputIterator,
class Predicate>
1018 bool any_of(InputIterator first, InputIterator last, Predicate Pred)
1020 for(; first != last; ++first)
1032 template<
typename T,
class Predicate>
1046 template<
class InputIterator,
class Predicate>
1047 bool none_of(InputIterator first, InputIterator last, Predicate Pred)
1049 for (; first != last; ++first)
1061 template<
typename T,
class Predicate>
1073 #endif // of ifndef UTIL_STL_DTK_HPP_
Definition: util_stl_dtk.hpp:917
Functor comparison object.
Definition: util_stl_dtk.hpp:27
void reduce()
Definition: util_stl_dtk.hpp:875
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
const_iterator begin() const
Definition: util_stl_dtk.hpp:891
T max_element() const
Definition: util_stl_dtk.hpp:821
bool any_of(InputIterator first, InputIterator last, Predicate Pred)
Test if any element in range fulfills condition, returns true if pred returns true for any of the ele...
Definition: util_stl_dtk.hpp:1018
Dtk_Size_t GetSize() const
Definition: util_stl_dtk.hpp:871
const T & back() const
Return the elements at the end of the array.
Definition: util_stl_dtk.hpp:552
T value_type
Definition: util_stl_dtk.hpp:207
void pop_back()
Removes the last element.
Definition: util_stl_dtk.hpp:485
Dtk_pair(Pair &&p)
Definition: util_stl_dtk.hpp:928
T * pointer
Definition: util_stl_dtk.hpp:208
iterator end()
Definition: util_stl_dtk.hpp:899
size_t Dtk_Size_t
Definition: define.h:712
~Dtk_tab()
Definition: util_stl_dtk.hpp:233
int operator<(const Dtk_tab< T > &t) const
Definition: util_stl_dtk.hpp:323
void sort()
Swap two elements.
Definition: util_stl_dtk.hpp:711
Functor comparison object.
Definition: util_stl_dtk.hpp:41
int operator==(const Dtk_tab< T > &t) const
Definition: util_stl_dtk.hpp:287
T & back()
Return the elements at the end of the array.
Definition: util_stl_dtk.hpp:537
int operator<(const Dtk_pair< T1, T2 > &t) const
Definition: util_stl_dtk.hpp:938
const_pointer const_iterator
Definition: util_stl_dtk.hpp:211
Dtk_pair(const T1 &a, const T2 &b)
Definition: util_stl_dtk.hpp:922
void remove(const T &a)
Removes the first element with the value a.
Definition: util_stl_dtk.hpp:690
T1 first
Definition: util_stl_dtk.hpp:919
T & operator[](Dtk_Size_t k)
Accesses the ith element - like a classic array -.
Definition: util_stl_dtk.hpp:380
const T & at(Dtk_Size_t k) const
Definition: util_stl_dtk.hpp:400
const T * GetArray() const
Returns array of T elements.
Definition: util_stl_dtk.hpp:243
int find(const T &e) const
Definition: util_stl_dtk.hpp:742
#define Pdtk_Assert(X)
Definition: define.h:742
Dtk_tab()
Default constructor.
Definition: util_stl_dtk.hpp:215
friend std::ostream & operator<<(std::ostream &o, const Dtk_pair &d)
Definition: util_stl_dtk.hpp:933
void sort(const comp &C)
Sorts the array with custom sorting.
Definition: util_stl_dtk.hpp:731
Dtk_tab(Dtk_Size_t initreservesize, int resize=0)
Definition: util_stl_dtk.hpp:221
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
bool all_of(InputIterator first, InputIterator last, Predicate Pred)
Test condition on all elements in range, and returns true if pred returns true for all the elements i...
Definition: util_stl_dtk.hpp:989
Dtk_Size_t max_ithelement()
Definition: util_stl_dtk.hpp:845
Dtk_pair< T1, T2 > make_Dtkpair(T1 &&x, T2 &&y)
Constructs a pair object with its first element set to x and its second element set to y.
Definition: util_stl_dtk.hpp:973
Dtk_tab< T > & operator=(Dtk_tab< T > &&t) DTK_NOEXCEPT
Move assignment operator.
Definition: util_stl_dtk.hpp:306
T2 second
Definition: util_stl_dtk.hpp:920
const_iterator cend() const
Definition: util_stl_dtk.hpp:907
void reserve(Dtk_Size_t n)
Definition: util_stl_dtk.hpp:797
const_iterator end() const
Definition: util_stl_dtk.hpp:903
int find(const T &e, const comp &C) const
Definition: util_stl_dtk.hpp:750
void Dtk_ThrowOverflowException()
Dtk_Size_t min_ithelement()
Definition: util_stl_dtk.hpp:831
void reverse()
Definition: util_stl_dtk.hpp:885
T min_element() const
Definition: util_stl_dtk.hpp:811
int operator()(const T &t1, const T &t2) const
Overloaded method comparison.
Definition: util_stl_dtk.hpp:44
void resize(Dtk_Size_t n)
Definition: util_stl_dtk.hpp:626
const T & operator[](Dtk_Size_t k) const
Definition: util_stl_dtk.hpp:388
Definition: util_stl_dtk.hpp:982
Dtk_tab subtab(Dtk_Size_t a, Dtk_Size_t b)
Definition: util_stl_dtk.hpp:788
int operator()(const T &t1, const T &t2) const
Overloaded method comparison.
Definition: util_stl_dtk.hpp:30
This is a high level array class.
Definition: util_stl_dtk.hpp:85
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:502
bool none_of(InputIterator first, InputIterator last, Predicate Pred)
Test if no elements fulfill condition, returns true if pred returns false for all the elements in the...
Definition: util_stl_dtk.hpp:1047
Dtk_tab & operator+=(const Dtk_tab &t)
Definition: util_stl_dtk.hpp:758
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
friend std::ostream & operator<<(std::ostream &o, const Dtk_tab &d)
Definition: util_stl_dtk.hpp:860
Dtk_tab & operator+=(Dtk_tab &&t)
Definition: util_stl_dtk.hpp:773
const_iterator cbegin() const
Definition: util_stl_dtk.hpp:895
T & at(Dtk_Size_t k)
Definition: util_stl_dtk.hpp:396
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
Dtk_tab(const Dtk_tab< T > &t)
Definition: util_stl_dtk.hpp:247
pointer iterator
Definition: util_stl_dtk.hpp:210
const T & front() const
Return the elements at the beginning of the array.
Definition: util_stl_dtk.hpp:582
T const * const_pointer
Definition: util_stl_dtk.hpp:209
iterator begin()
Definition: util_stl_dtk.hpp:887
Dtk_tab & operator=(const Dtk_tab< T > &t)
Definition: util_stl_dtk.hpp:266
int operator==(const Dtk_pair< T1, T2 > &t) const
Definition: util_stl_dtk.hpp:946
Dtk_pair(Arg &&a, Arg2 &&b)
Definition: util_stl_dtk.hpp:924
Dtk_pair()
Definition: util_stl_dtk.hpp:921
#define DTK_NOEXCEPT
Definition: config.hpp:26