10 #ifndef INCLUDED_O3TL_SORTED_VECTOR_HXX
11 #define INCLUDED_O3TL_SORTED_VECTOR_HXX
17 #include <type_traits>
23 template<
class Value,
class Compare>
34 typename Compare = std::less<Value>,
35 template<
typename,
typename>
class Find =
find_unique,
36 bool = std::is_copy_constructible<Value>::value >
42 typedef typename std::vector<Value>::iterator
iterator;
47 typedef typename std::vector<Value>::size_type
size_type;
64 std::pair<const_iterator,bool>
insert( Value&& x )
70 return std::make_pair(it,
true);
72 return std::make_pair(ret.first,
false);
75 std::pair<const_iterator,bool>
insert(
const Value& x )
81 return std::make_pair(it,
true);
83 return std::make_pair(ret.first,
false);
86 size_type
erase(
const Value& x )
103 const_iterator
erase(const_iterator
const& position)
108 void erase(const_iterator
const& first, const_iterator
const& last)
159 const_iterator
end()
const
171 const_reverse_iterator
rend()
const
188 return m_vector.operator[]( index );
209 const_iterator
find(
const Value& x )
const
212 return (ret.second) ? ret.first :
m_vector.end();
215 size_type
count(
const Value& v)
const
217 return find(v) !=
end() ? 1 : 0;
240 for (const_iterator it = rOther.
m_vector.begin(); it != rOther.
m_vector.end(); ++it)
279 template<
typename,
typename>
class Find >
298 Value tmp(const_cast<typename Value::element_type*>(x));
299 auto ret = super_sorted_vector::find(tmp);
308 Value tmp(const_cast<typename Value::element_type*>(x));
309 auto ret = super_sorted_vector::upper_bound(tmp);
318 Value tmp(const_cast<typename Value::element_type*>(x));
319 auto ret = super_sorted_vector::lower_bound(tmp);
333 return (*lhs) < (*rhs);
339 bool operator() ( std::unique_ptr<T>
const& lhs, std::unique_ptr<T>
const& rhs )
const
341 return (*lhs) < (*rhs);
348 template<
class Value,
class Compare>
351 typedef typename sorted_vector<
Value, Compare,
354 const_iterator first, const_iterator last,
357 const_iterator
const it = std::lower_bound(first, last, v, Compare());
358 return std::make_pair(it, (it != last && !Compare()(v, *it)));
365 template<
class Value,
class Compare>
371 const_iterator first, const_iterator last,
374 std::pair<const_iterator, const_iterator>
const its =
375 std::equal_range(first, last, v, Compare());
376 for (const_iterator it = its.first; it != its.second; ++it)
380 return std::make_pair(it,
true);
383 return std::make_pair(its.first,
false);
std::pair< const_iterator, bool > operator()(const_iterator first, const_iterator last, Value const &v)
const_iterator lower_bound(const Value &x) const
const Value & back() const
void insert(sorted_vector< Value, Compare, Find > const &rOther)
size_type count(const Value &v) const
std::pair< const_iterator, bool > insert(const Value &x)
std::vector< Value >::difference_type difference_type
super_sorted_vector::const_iterator lower_bound(typename Value::element_type const *x) const
implement lower_bound for sorted_vectors containing std::unique_ptr
std::vector< Value > vector_t
const_iterator find(const Value &x) const
void erase_at(size_t index)
void swap(sorted_vector &other)
bool operator()(T *const &lhs, T *const &rhs) const
const Value & front() const
Implements an ordering function over a pointer, where the comparison uses the < operator on the point...
super_sorted_vector::const_iterator find(typename Value::element_type const *x) const
implement find for sorted_vectors containing std::unique_ptr
bool operator==(const sorted_vector &other) const
void reserve(size_type amount)
bool operator!=(const sorted_vector &other) const
const_iterator erase(const_iterator const &position)
const_iterator upper_bound(const Value &x) const
void DeleteAndDestroyAll()
the elements are partially ordered by Compare, 2 elements are allowed if they are not the same elemen...
super_sorted_vector::const_iterator upper_bound(typename Value::element_type const *x) const
implement upper_bound for sorted_vectors containing std::unique_ptr
Find< Value, Compare > Find_t
std::vector< Value >::const_reverse_iterator const_reverse_iterator
sorted_vector & operator=(sorted_vector const &)=default
std::pair< const_iterator, bool > operator()(const_iterator first, const_iterator last, Value const &v)
const_iterator end() const
sorted_vector< Value, Compare, Find, true > super_sorted_vector
const_reverse_iterator rend() const
const_iterator begin() const
const_reverse_iterator rbegin() const
constexpr sorted_vector(std::initializer_list< Value > init)
Value erase_extract(size_t index)
make erase return the removed element, otherwise there is no useful way of extracting a std::unique_p...
bool operator()(std::unique_ptr< T > const &lhs, std::unique_ptr< T > const &rhs) const
const Value & operator[](size_t index) const
std::vector< Value >::iterator iterator
the elements are totally ordered by Compare, for no 2 elements !Compare(a,b) && !Compare(b,a) is true
sorted_vector< Value, Compare, o3tl::find_unique >::const_iterator const_iterator
std::pair< const_iterator, bool > insert(Value &&x)
void erase(const_iterator const &first, const_iterator const &last)
std::vector< Value >::size_type size_type
sorted_vector< Value, Compare, o3tl::find_partialorder_ptrequals >::const_iterator const_iterator
std::vector< Value >::const_iterator const_iterator
Represents a sorted vector of values.
size_type erase(const Value &x)