31 #ifndef COMMON_STD_SET_H 32 #define COMMON_STD_SET_H 34 #include "common/array.h" 41 template<
class T,
class Comparitor = Common::Less<T> >
44 static int ComparatorFn(
const T &a,
const T &b) {
45 return Comparitor().operator()(a, b) ? -1 : 0;
48 static bool CompareEq(
const T &a,
const T &b) {
49 return !ComparatorFn(a, b) && !ComparatorFn(b, a);
55 Entry(
const T &item) : _value(item) {
59 using iterator =
typename Common::SortedArray<T, const T &>::iterator;
74 iterator mid = begin + (Common::distance(begin, end) / 2);
75 if (ComparatorFn(item, *mid))
77 else if (ComparatorFn(*mid, item))
113 if (first == this->
end())
116 while (end != this->
end() && CompareEq(*first, *end)) {
119 size_t erased = Common::distance(first, end);
120 this->
erase(first, end);
130 if (CompareEq(*it, item))
132 else if (!ComparatorFn(item, *it))
size_t erase(const T &item)
Definition: set.h:111
iterator find(const T &item)
Definition: set.h:70
iterator end()
Definition: array.h:379
iterator begin()
Definition: array.h:374
T * iterator
Definition: array.h:54
Entry insert(const T &item)
Definition: set.h:88
const T * const_iterator
Definition: array.h:55
void erase(iterator first, iterator last)
Definition: set.h:103
void erase(iterator item)
Definition: set.h:96
size_t count(const T item) const
Definition: set.h:127
void insert(const T &element)
Definition: array.h:571
Definition: algorithm.h:37
iterator erase(iterator pos)
Definition: array.h:328