14 #ifndef ORDERED_VECTOR_H 15 #define ORDERED_VECTOR_H 16 #ifdef CPPPARSER // hack around this for interigate... 22 template<
class Key,
class Compare = std::less<
int>,
class Vector = pvector<Key> >
class ov_multiset 26 template<
class Key,
class Compare = std::less<
int>,
class Vector = pvector<Key> >
class ov_set 30 template<
class Key,
class Compare = std::less<
int>,
class Vector = pvector<Key> >
class ordered_vector 55 #define KEY_TYPE key_type_0 56 #define VALUE_TYPE value_type_0 57 #define REFERENCE reference_0 58 #define CONST_REFERENCE const_reference_0 59 #define KEY_COMPARE key_compare_0 60 #define VALUE_COMPARE value_compare_0 61 #define ITERATOR iterator_0 62 #define CONST_ITERATOR const_iterator_0 63 #define REVERSE_ITERATOR reverse_iterator_0 64 #define CONST_REVERSE_ITERATOR const_reverse_iterator_0 65 #define DIFFERENCE_TYPE difference_type_0 66 #define SIZE_TYPE size_type_0 94 template<
class Key,
class Compare = std::less<Key>,
class Vector = pvector<Key> >
99 typedef Key VALUE_TYPE;
100 typedef Key &REFERENCE;
101 typedef const Key &CONST_REFERENCE;
102 typedef Compare KEY_COMPARE;
103 typedef Compare VALUE_COMPARE;
108 typedef typename Vector::iterator ITERATOR;
109 typedef typename Vector::const_iterator CONST_ITERATOR;
110 typedef typename Vector::reverse_iterator REVERSE_ITERATOR;
111 typedef typename Vector::const_reverse_iterator CONST_REVERSE_ITERATOR;
113 typedef typename Vector::difference_type DIFFERENCE_TYPE;
114 typedef typename Vector::size_type SIZE_TYPE;
119 typedef KEY_TYPE key_type;
120 typedef VALUE_TYPE value_type;
121 typedef REFERENCE reference;
122 typedef CONST_REFERENCE const_reference;
123 typedef KEY_COMPARE key_compare;
124 typedef VALUE_COMPARE value_compare;
125 typedef ITERATOR iterator;
126 typedef CONST_ITERATOR const_iterator;
127 typedef REVERSE_ITERATOR reverse_iterator;
128 typedef CONST_REVERSE_ITERATOR const_reverse_iterator;
129 typedef DIFFERENCE_TYPE difference_type;
130 typedef SIZE_TYPE size_type;
140 INLINE ITERATOR
begin();
141 INLINE ITERATOR
end();
142 INLINE REVERSE_ITERATOR
rbegin();
143 INLINE REVERSE_ITERATOR
rend();
145 INLINE CONST_ITERATOR
begin()
const;
146 INLINE CONST_ITERATOR
end()
const;
147 INLINE CONST_REVERSE_ITERATOR
rbegin()
const;
148 INLINE CONST_REVERSE_ITERATOR
rend()
const;
150 INLINE CONST_ITERATOR
cbegin()
const;
151 INLINE CONST_ITERATOR
cend()
const;
152 INLINE CONST_REVERSE_ITERATOR
crbegin()
const;
153 INLINE CONST_REVERSE_ITERATOR
crend()
const;
156 INLINE reference operator [] (SIZE_TYPE n);
157 INLINE const_reference operator [] (SIZE_TYPE n)
const;
159 INLINE reference
front();
160 INLINE const_reference
front()
const;
162 INLINE reference
back();
163 INLINE const_reference
back()
const;
166 INLINE SIZE_TYPE
size()
const;
168 INLINE
bool empty()
const;
180 ITERATOR insert_unique(ITERATOR position,
const VALUE_TYPE &key);
181 ITERATOR insert_nonunique(ITERATOR position,
const VALUE_TYPE &key);
182 INLINE std::pair<ITERATOR, bool> insert_unique(
const VALUE_TYPE &key);
183 INLINE ITERATOR insert_nonunique(
const VALUE_TYPE &key);
187 INLINE ITERATOR erase(ITERATOR position);
188 INLINE SIZE_TYPE erase(
const KEY_TYPE &key);
189 INLINE
void erase(ITERATOR first, ITERATOR last);
193 INLINE ITERATOR find(
const KEY_TYPE &key);
194 INLINE CONST_ITERATOR find(
const KEY_TYPE &key)
const;
195 INLINE ITERATOR find_particular(
const KEY_TYPE &key);
196 INLINE CONST_ITERATOR find_particular(
const KEY_TYPE &key)
const;
197 INLINE SIZE_TYPE
count(
const KEY_TYPE &key)
const;
199 INLINE ITERATOR lower_bound(
const KEY_TYPE &key);
200 INLINE CONST_ITERATOR lower_bound(
const KEY_TYPE &key)
const;
201 INLINE ITERATOR upper_bound(
const KEY_TYPE &key);
202 INLINE CONST_ITERATOR upper_bound(
const KEY_TYPE &key)
const;
203 INLINE std::pair<ITERATOR, ITERATOR> equal_range(
const KEY_TYPE &key);
204 INLINE std::pair<CONST_ITERATOR, CONST_ITERATOR> equal_range(
const KEY_TYPE &key)
const;
208 INLINE
void reserve(SIZE_TYPE n);
211 bool verify_list_unique()
const;
212 bool verify_list_nonunique()
const;
214 INLINE
void push_back(
const VALUE_TYPE &key);
217 INLINE
void resize(SIZE_TYPE n);
218 INLINE
void resize(SIZE_TYPE n,
const VALUE_TYPE &value);
221 INLINE ITERATOR nci(CONST_ITERATOR i);
222 INLINE ITERATOR find_insert_position(ITERATOR first, ITERATOR last,
223 const KEY_TYPE &key);
224 ITERATOR r_find_insert_position(ITERATOR first, ITERATOR last,
225 const KEY_TYPE &key);
226 CONST_ITERATOR r_find(CONST_ITERATOR first, CONST_ITERATOR last,
227 CONST_ITERATOR not_found,
228 const KEY_TYPE &key)
const;
229 CONST_ITERATOR r_find_particular(CONST_ITERATOR first, CONST_ITERATOR last,
230 CONST_ITERATOR not_found,
231 const KEY_TYPE &key)
const;
232 SIZE_TYPE r_count(CONST_ITERATOR first, CONST_ITERATOR last,
233 const KEY_TYPE &key)
const;
234 CONST_ITERATOR r_lower_bound(CONST_ITERATOR first, CONST_ITERATOR last,
235 const KEY_TYPE &key)
const;
236 CONST_ITERATOR r_upper_bound(CONST_ITERATOR first, CONST_ITERATOR last,
237 const KEY_TYPE &key)
const;
238 std::pair<CONST_ITERATOR, CONST_ITERATOR>
239 r_equal_range(CONST_ITERATOR first, CONST_ITERATOR last,
240 const KEY_TYPE &key)
const;
244 class EquivalentTest {
250 INLINE EquivalentTest(
const Compare &compare) :
251 _compare(compare) { }
252 INLINE
bool operator () (
const KEY_TYPE &a,
const KEY_TYPE &b) {
253 nassertr(!_compare(b, a),
false);
254 return !_compare(a, b);
268 template<
class Key,
class Compare = std::less<Key>,
class Vector = pvector<Key> >
275 INLINE
ov_set(
const Compare &compare,
278 INLINE ITERATOR insert(ITERATOR position,
const VALUE_TYPE &key0);
279 INLINE std::pair<ITERATOR, bool> insert(
const VALUE_TYPE &key0);
289 template<
class Key,
class Compare = std::less<Key>,
class Vector = pvector<Key> >
299 INLINE ITERATOR insert(ITERATOR position,
const VALUE_TYPE &key);
300 INLINE ITERATOR insert(
const VALUE_TYPE &key);
307 #include "ordered_vector.T" 308 #endif // cppparser .. This template class presents an interface similar to the STL set or multiset (and ov_set and ov_multi...
bool operator >(const ordered_vector< Key, Compare, Vector > &other) const
Returns true if this ordered vector sorts lexicographically after the other one, false otherwise.
void pop_back()
Removes the last element at the end of the vector.
bool operator !=(const ordered_vector< Key, Compare, Vector > &other) const
Returns true if the two ordered vectors are not memberwise equivalent, false if they are.
void sort_unique()
Ensures that the vector is properly sorted after a potentially damaging operation.
size_type_0 size() const
Returns the number of elements in the ordered vector.
void clear()
Removes all elements from the ordered vector.
void sort_nonunique()
Ensures that the vector is properly sorted after a potentially damaging operation.
bool verify_list() const
Maps to verify_list_unique().
bool verify_list() const
Maps to verify_list_nonunique().
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
reference back()
Returns a reference to the first element.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
void reserve(size_type_0 n)
Informs the vector of a planned change in size; ensures that the capacity of the vector is greater th...
bool operator==(const ordered_vector< Key, Compare, Vector > &other) const
Returns true if the two ordered vectors are memberwise equivalent, false otherwise.
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
const_iterator_0 cbegin() const
Returns the iterator that marks the first element in the ordered vector.
void swap(ordered_vector< Key, Compare, Vector > &other)
Exchanges the contents of this vector and the other vector, in constant time (e.g....
bool operator<(const ordered_vector< Key, Compare, Vector > &other) const
Returns true if this ordered vector sorts lexicographically before the other one, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
reference front()
Returns a reference to the first element.
iterator_0 insert_unverified(iterator_0 position, const value_type_0 &key)
Inserts the indicated key into the ordered vector at the indicated place.
const_reverse_iterator_0 crend() const
Returns the iterator that marks the end of the ordered vector, when viewed in reverse order.
size_type_0 max_size() const
Returns the maximum number of elements that can possibly be stored in an ordered vector.
void sort()
Maps to sort_nonunique().
const_iterator_0 cend() const
Returns the iterator that marks the end of the ordered vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void sort()
Maps to sort_unique().
reverse_iterator_0 rbegin()
Returns the iterator that marks the first element in the ordered vector, when viewed in reverse order...
A specialization of ordered_vector that emulates a standard STL set: many copies of each element are ...
bool operator >=(const ordered_vector< Key, Compare, Vector > &other) const
Returns true if this ordered vector sorts lexicographically after the other one or is equivalent,...
void push_back(const value_type_0 &key)
Adds the new element to the end of the vector without regard for proper sorting.
reverse_iterator_0 rend()
Returns the iterator that marks the end of the ordered vector, when viewed in reverse order.
size_type_0 count(const key_type_0 &key) const
Returns the number of elements that sort equivalent to the key that are in the vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const_reverse_iterator_0 crbegin() const
Returns the iterator that marks the first element in the ordered vector, when viewed in reverse order...
TypeHandle is the identifier used to differentiate C++ class types.
bool operator<=(const ordered_vector< Key, Compare, Vector > &other) const
Returns true if this ordered vector sorts lexicographically before the other one or is equivalent,...