54 template <
typename T,
typename container >
55 index_t
find(
const container& in,
const T& value )
57 auto it =
std::find( in.begin(), in.end(), value );
64 return static_cast< index_t
>( it - in.begin() );
72 template <
typename T,
typename container >
75 auto low = std::lower_bound( in.begin(), in.end(), value );
76 if( low == in.end() || value < *low )
82 return static_cast< index_t
>( low - in.begin() );
86 template <
typename T,
typename container >
87 bool contains(
const container& in,
const T& value )
89 return find( in, value ) != NO_ID;
92 template <
typename T,
typename container >
103 template <
typename T1,
typename T2 >
106 if( input.size() < 2 )
110 for(
auto it1 :
range( input.size() - 1 ) )
112 index_t ref_index = it1;
113 T1 ref_value = input[it1];
114 for(
auto it2 :
range( it1 + 1, input.size() ) )
116 index_t new_index = it2;
117 T1 new_value = input[it2];
118 if( ref_value > new_value )
120 ref_value = new_value;
121 ref_index = new_index;
124 std::iter_swap( input.begin() + it1, input.begin() + ref_index );
125 std::iter_swap( output.begin() + it1, output.begin() + ref_index );
134 template <
typename CONTAINER,
typename CMP >
137 std::sort( container.begin(), container.end(), cmp );
138 container.erase( std::unique( container.begin(), container.end(), cmp ),
146 template <
typename CONTAINER >
149 std::sort( container.begin(), container.end() );
150 container.erase( std::unique( container.begin(), container.end() ),
index_t find_sorted(const container &in, const T &value)
Returns the position of the first entity matching.
void sort_unique(CONTAINER &container, const CMP &cmp)
Sorts a container and suppresses all duplicated entities.
index_t find(const container &in, const T &value)
Returns the position of the first entity matching.
bool contains_sorted(const container &in, const T &value)
bool contains(const container &in, const T &value)
Classes to build GeoModel from various inputs.
void indirect_sort(std::vector< T1 > &input, std::vector< T2 > &output)
Bubble sorting of input and output vectors according to values of input.