36#include <EASTL/sort.h>
37#include <EASTL/vector.h>
41 template<
typename Type>
44 template<
typename T,
typename Type>
46 template<
typename T,
typename... Ts>
48 template<
typename T,
typename... Ts>
51 template <typename T, size_t nodeCount, bool bEnableOverflow = true, typename OverflowAllocator = typename eastl::type_select<bEnableOverflow, EASTLAllocatorType, EASTLDummyAllocatorType>::type>
52 inline void efficient_clear(eastl::fixed_vector<T, nodeCount, bEnableOverflow, OverflowAllocator> & fixed_vector)
54 if constexpr (bEnableOverflow)
60 fixed_vector.reset_lose_memory();
64 template<
typename T,
typename A>
70 template<
typename T,
typename Pred,
typename A>
71 typename eastl::vector<T, A>::iterator
insert_sorted( eastl::vector<T, A>& vec, T
const& item, Pred&& pred )
73 return vec.insert( eastl::upper_bound( eastl::begin( vec ), eastl::end( vec ), item, pred ), item );
76 template<
typename T,
typename A>
79 if ( eastl::find( eastl::cbegin( target ), eastl::cend( target ), item ) == eastl::cend( target ) )
81 target.push_back( item );
86 template<
typename T,
typename A1,
typename A2>
87 void insert_unique( eastl::vector<T, A1>& target,
const eastl::vector<T, A2>& source )
89 eastl::for_each( eastl::cbegin( source ), eastl::cend( source ),
90 [&target]( T
const& item )
96 template<
typename T,
typename A1,
typename A2>
97 void insert( eastl::vector<T, A1>& target,
const eastl::vector<T, A2>& source )
99 target.insert( end( target ), begin( source ), end( source ) );
102 template <
typename T,
typename A>
103 bool contains( eastl::vector<T, A>& vec,
const T& val )
105 return eastl::find( vec.cbegin(), vec.cend(), val ) != vec.cend();
108 template <
typename T,
typename A,
class Predicate>
111 return erase_if( vec, pred ) > 0u;
114 template<
typename T,
typename A>
117 assert( !vec.empty() );
118 vec.erase( eastl::begin( vec ) );
121 template<
typename T,
typename A1,
typename A2>
122 void unchecked_copy( eastl::vector<T, A1>& dst,
const eastl::vector<T, A2>& src )
124 dst.resize( src.size() );
125 memcpy( dst.data(), src.data(), src.size() *
sizeof( T ) );
128 template<
typename T,
typename U,
typename A>
129 eastl::vector<T, A>
convert(
const eastl::vector<U, A>& data )
131 return eastl::vector<T, A>( eastl::cbegin( data ), eastl::cend( data ) );
134 template<
typename Cont,
typename It>
135 auto ToggleIndices( Cont& cont, It beg, It end ) ->
decltype(eastl::end( cont ))
138 return eastl::stable_partition( eastl::begin( cont ), eastl::end( cont ),
139 [&]( [[maybe_unused]]
decltype(*eastl::begin( cont ))
const& val ) ->
bool
141 return eastl::find( beg, end, helpIndx++ ) == end;
145 template<
typename Cont,
typename IndCont>
148 for (
auto it = indices.rbegin(); it != indices.rend(); ++it )
150 cont.erase( cont.begin() + *it );
154 template<
typename Cont,
typename IndCont>
157 eastl::sort( indices.begin(), indices.end() );
163 template<
typename T,
typename A1,
typename A2>
164 eastl::vector<T, A1>
erase_indices(
const eastl::vector<T, A1>& data, eastl::vector<size_t, A2>& indicesToDelete )
166 eastl::sort( begin( indicesToDelete ), end( indicesToDelete ) );
170 template<
typename T,
typename A1,
typename A2>
171 eastl::vector<T, A1>
erase_sorted_indices(
const eastl::vector<T, A1>& data, eastl::vector<size_t, A2>& indicesToDelete )
173 if ( indicesToDelete.empty() )
177 assert( indicesToDelete.size() <= data.size() );
179 eastl::vector<T, A1> ret;
180 ret.reserve( data.size() - indicesToDelete.size() );
183 typename eastl::vector<T, A1>::const_iterator itBlockBegin = eastl::cbegin( data );
184 for (
size_t it : indicesToDelete )
186 typename eastl::vector<T, A1>::const_iterator itBlockEnd = eastl::cbegin( data ) + it;
187 if ( itBlockBegin != itBlockEnd )
189 eastl::copy( itBlockBegin, itBlockEnd, eastl::back_inserter( ret ) );
191 itBlockBegin = itBlockEnd + 1;
195 if ( itBlockBegin != data.end() )
197 eastl::copy( itBlockBegin, eastl::cend( data ), eastl::back_inserter( ret ) );
Handle console commands that start with a forward slash.
eastl::vector< T, A1 > erase_indices(const eastl::vector< T, A1 > &data, eastl::vector< size_t, A2 > &indicesToDelete)
eastl::vector< T, A >::iterator insert_sorted(eastl::vector< T, A > &vec, T const &item, Pred &&pred)
void pop_front(eastl::vector< T, A > &vec)
eastl::vector< T, A > convert(const eastl::vector< U, A > &data)
void insert(eastl::vector< T, A1 > &target, const eastl::vector< T, A2 > &source)
eastl::vector< Type > vector
void unchecked_copy(eastl::vector< T, A1 > &dst, const eastl::vector< T, A2 > &src)
void EraseIndices(Cont &cont, IndCont &indices)
void efficient_clear(eastl::fixed_vector< T, nodeCount, bEnableOverflow, OverflowAllocator > &fixed_vector)
auto ToggleIndices(Cont &cont, It beg, It end) -> decltype(eastl::end(cont))
eastl::vector< T, A1 > erase_sorted_indices(const eastl::vector< T, A1 > &data, eastl::vector< size_t, A2 > &indicesToDelete)
bool contains(eastl::vector< T, A > &vec, const T &val)
void EraseIndicesSorted(Cont &cont, IndCont &indices)
void insert_unique(eastl::vector< T, A > &target, const T &item)
bool dvd_erase_if(eastl::vector< T, A > &vec, Predicate &&pred)