16 #ifndef ASSOCVECTOR_INC_
17 #define ASSOCVECTOR_INC_
33 template <
class Value,
class C>
36 typedef std::pair<typename C::first_argument_type, Value>
38 typedef typename C::first_argument_type first_argument_type;
48 const first_argument_type& rhs)
const
49 {
return C::operator()(lhs, rhs); }
55 const first_argument_type& rhs)
const
59 const Data& rhs)
const
79 class C = std::less<K>,
80 class A = std::allocator< std::pair<K, V> >
83 :
private std::vector< std::pair<K, V>, A >
86 typedef std::vector<std::pair<K, V>, A> Base;
108 :
public std::binary_function<value_type, value_type, bool>
119 {
return key_compare::operator()(lhs.first, rhs.first); }
125 const A& alloc = A())
129 template <
class InputIterator>
132 const A& alloc = A())
133 : Base(first, last, alloc),
MyCompare(comp)
157 bool empty()
const {
return Base::empty(); }
171 if (i ==
end() || this->
operator()(val.first, i->first))
173 i = Base::insert(i, val);
176 return std::make_pair(i, !found);
181 if (pos !=
end() && this->
operator()(*pos, val) &&
183 !this->
operator()(val, pos[1]) &&
184 this->
operator()(pos[1], val)))
186 return Base::insert(pos, val);
191 template <
class InputIterator>
192 void insert(InputIterator first, InputIterator last)
193 {
for (; first != last; ++first)
insert(*first); }
196 { Base::erase(pos); }
201 if (i ==
end())
return 0;
207 { Base::erase(first, last); }
235 if (i !=
end() && this->
operator()(k, i->first))
245 if (i !=
end() && this->
operator()(k, i->first))
258 return std::lower_bound(
begin(),
end(), k, me);
264 return std::lower_bound(
begin(),
end(), k, me);
270 return std::upper_bound(
begin(),
end(), k, me);
276 return std::upper_bound(
begin(),
end(), k, me);
282 return std::equal_range(
begin(),
end(), k, me);
289 return std::equal_range(
begin(),
end(), k, me);
294 const Base& me = lhs;
300 const Base& me = *
this;
301 const Base& yo = rhs;
306 {
return !(lhs == rhs); }
309 {
return rhs < lhs; }
312 {
return !(lhs < rhs); }
315 {
return !(rhs < lhs); }
319 template <
class K,
class V,
class C,
class A>
336 #endif // ASSOCVECTOR_INC_
AssocVectorCompare(const C &src)
A::const_pointer const_pointer
std::pair< const_iterator, const_iterator > equal_range(const key_type &k) const
bool operator()(const Data &lhs, const Data &rhs) const
Base::const_iterator const_iterator
void erase(iterator first, iterator last)
std::pair< iterator, bool > insert(const value_type &val)
friend bool operator>(const AssocVector &lhs, const AssocVector &rhs)
bool operator()(const first_argument_type &lhs, const Data &rhs) const
size_type erase(const key_type &k)
const_reverse_iterator rbegin() const
const_reverse_iterator rend() const
size_type count(const key_type &k) const
Base::const_reverse_iterator const_reverse_iterator
const_iterator end() const
const_iterator find(const key_type &k) const
Base::value_type value_type
friend bool operator==(const AssocVector &lhs, const AssocVector &rhs)
bool operator()(const first_argument_type &lhs, const first_argument_type &rhs) const
std::pair< iterator, iterator > equal_range(const key_type &k)
iterator insert(iterator pos, const value_type &val)
Base::difference_type difference_type
A::const_reference const_reference
void swap(AssocVector &other)
Base::reverse_iterator reverse_iterator
void swap(AssocVector< K, V, C, A > &lhs, AssocVector< K, V, C, A > &rhs)
value_compare(key_compare pred)
bool operator()(const Data &lhs, const first_argument_type &rhs) const
AssocVector(const key_compare &comp=key_compare(), const A &alloc=A())
friend bool operator>=(const AssocVector &lhs, const AssocVector &rhs)
reverse_iterator rbegin()
value_compare value_comp() const
key_compare key_comp() const
AssocVector(InputIterator first, InputIterator last, const key_compare &comp=key_compare(), const A &alloc=A())
DEVICEHOST void swap(Real &a, Real &b)
bool operator()(const value_type &lhs, const value_type &rhs) const
void insert(InputIterator first, InputIterator last)
friend bool operator<=(const AssocVector &lhs, const AssocVector &rhs)
const_iterator lower_bound(const key_type &k) const
iterator lower_bound(const key_type &k)
iterator find(const key_type &k)
iterator upper_bound(const key_type &k)
const_iterator upper_bound(const key_type &k) const
AssocVector & operator=(const AssocVector &rhs)
const_iterator begin() const
bool operator<(const AssocVector &rhs) const
Base::size_type size_type
mapped_type & operator[](const key_type &key)
friend bool operator!=(const AssocVector &lhs, const AssocVector &rhs)