22 #ifndef HPL1_STD_MULTISET_H 23 #define HPL1_STD_MULTISET_H 25 #include "common/rb_tree.h" 30 template<
class T,
class CompFn = Common::Less<T> >
39 return _items.
begin();
46 const_iterator begin()
const {
47 return _items.
begin();
50 const_iterator end()
const {
59 return _items.
size() == 0;
69 iterator
find(
const T &item) {
71 if (it != _items.
end() && CompareEq(*it, item)) {
77 iterator insert(
const T &item) {
78 return _items.
insert(item);
81 void erase(iterator item) {
85 void erase(iterator first, iterator last) {
86 _items.
erase(first, last);
89 size_t erase(
const T &item) {
91 for (
auto it = _items.
lowerBound(item); it != end() && CompareEq(*it, item);) {
103 for (
auto it = _items.
lowerBound(item); it != end() && CompareEq(*it, item); ++it)
109 static bool CompareEq(
const T &a,
const T &b) {
110 return !CompFn()(a, b) && !CompFn()(b, a);
BasicIterator lowerBound(const Key &key)
Definition: rb_tree.h:181
BasicIterator insert(const ValueType &val)
Definition: rb_tree.h:302
iterator find(const T &item)
Definition: multiset.h:69
Iterator< const T &, const T *> ConstIterator
Definition: rb_tree.h:123
Iterator< T &, T *> BasicIterator
Definition: rb_tree.h:122
BasicIterator erase(BasicIterator it)
Definition: rb_tree.h:250
void clear()
Definition: rb_tree.h:158
size_t size() const
Definition: rb_tree.h:327
Definition: multiset.h:31
Definition: algorithm.h:37
BasicIterator begin()
Definition: rb_tree.h:166
Definition: algorithms.h:27
BasicIterator end()
Definition: rb_tree.h:172
size_t count(const T &item) const
Definition: multiset.h:101