Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/express/ordered_vector.I

Go to the documentation of this file.
00001 // Filename: ordered_vector.I
00002 // Created by:  drose (20Feb02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: ordered_vector::Constructor
00022 //       Access: Public
00023 //  Description: 
00024 ////////////////////////////////////////////////////////////////////
00025 template<class Key, class Compare>
00026 INLINE ordered_vector<Key, Compare>::
00027 ordered_vector(const Compare &compare) :
00028   _compare(compare)
00029 {
00030 }
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //     Function: ordered_vector::Copy Constructor
00034 //       Access: Public
00035 //  Description: 
00036 ////////////////////////////////////////////////////////////////////
00037 template<class Key, class Compare>
00038 INLINE ordered_vector<Key, Compare>::
00039 ordered_vector(const ordered_vector<Key, Compare> &copy) :
00040   _compare(copy._compare),
00041   _vector(copy._vector)
00042 {
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: ordered_vector::Copy Assignment Operator
00047 //       Access: Public
00048 //  Description: 
00049 ////////////////////////////////////////////////////////////////////
00050 template<class Key, class Compare>
00051 INLINE ordered_vector<Key, Compare> &ordered_vector<Key, Compare>::
00052 operator = (const ordered_vector<Key, Compare> &copy) {
00053   _compare = copy._compare;
00054   _vector = copy._vector;
00055   return *this;
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: ordered_vector::Destructor
00060 //       Access: Public
00061 //  Description: 
00062 ////////////////////////////////////////////////////////////////////
00063 template<class Key, class Compare>
00064 INLINE ordered_vector<Key, Compare>::
00065 ~ordered_vector() {
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: ordered_vector::begin
00070 //       Access: Public
00071 //  Description: Returns the iterator that marks the first element in
00072 //               the ordered vector.
00073 ////////////////////////////////////////////////////////////////////
00074 template<class Key, class Compare>
00075 INLINE TYPENAME ordered_vector<Key, Compare>::ITERATOR ordered_vector<Key, Compare>::
00076 begin() {
00077   return _vector.begin();
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function: ordered_vector::end
00082 //       Access: Public
00083 //  Description: Returns the iterator that marks the end of the
00084 //               ordered vector.
00085 ////////////////////////////////////////////////////////////////////
00086 template<class Key, class Compare>
00087 INLINE TYPENAME ordered_vector<Key, Compare>::ITERATOR ordered_vector<Key, Compare>::
00088 end() {
00089   return _vector.end();
00090 }
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //     Function: ordered_vector::rbegin
00094 //       Access: Public
00095 //  Description: Returns the iterator that marks the first element in
00096 //               the ordered vector, when viewed in reverse order.
00097 ////////////////////////////////////////////////////////////////////
00098 template<class Key, class Compare>
00099 INLINE TYPENAME ordered_vector<Key, Compare>::REVERSE_ITERATOR ordered_vector<Key, Compare>::
00100 rbegin() {
00101   return _vector.rbegin();
00102 }
00103 
00104 ////////////////////////////////////////////////////////////////////
00105 //     Function: ordered_vector::rend
00106 //       Access: Public
00107 //  Description: Returns the iterator that marks the end of the
00108 //               ordered vector, when viewed in reverse order.
00109 ////////////////////////////////////////////////////////////////////
00110 template<class Key, class Compare>
00111 INLINE TYPENAME ordered_vector<Key, Compare>::REVERSE_ITERATOR ordered_vector<Key, Compare>::
00112 rend() {
00113   return _vector.rend();
00114 }
00115 
00116 ////////////////////////////////////////////////////////////////////
00117 //     Function: ordered_vector::begin
00118 //       Access: Public
00119 //  Description: Returns the iterator that marks the first element in
00120 //               the ordered vector.
00121 ////////////////////////////////////////////////////////////////////
00122 template<class Key, class Compare>
00123 INLINE TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR ordered_vector<Key, Compare>::
00124 begin() const {
00125   return _vector.begin();
00126 }
00127 
00128 ////////////////////////////////////////////////////////////////////
00129 //     Function: ordered_vector::end
00130 //       Access: Public
00131 //  Description: Returns the iterator that marks the end of the
00132 //               ordered vector.
00133 ////////////////////////////////////////////////////////////////////
00134 template<class Key, class Compare>
00135 INLINE TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR ordered_vector<Key, Compare>::
00136 end() const {
00137   return _vector.end();
00138 }
00139 
00140 ////////////////////////////////////////////////////////////////////
00141 //     Function: ordered_vector::rbegin
00142 //       Access: Public
00143 //  Description: Returns the iterator that marks the first element in
00144 //               the ordered vector, when viewed in reverse order.
00145 ////////////////////////////////////////////////////////////////////
00146 template<class Key, class Compare>
00147 INLINE TYPENAME ordered_vector<Key, Compare>::CONST_REVERSE_ITERATOR ordered_vector<Key, Compare>::
00148 rbegin() const {
00149   return _vector.rbegin();
00150 }
00151 
00152 ////////////////////////////////////////////////////////////////////
00153 //     Function: ordered_vector::rend
00154 //       Access: Public
00155 //  Description: Returns the iterator that marks the end of the
00156 //               ordered vector, when viewed in reverse order.
00157 ////////////////////////////////////////////////////////////////////
00158 template<class Key, class Compare>
00159 INLINE TYPENAME ordered_vector<Key, Compare>::CONST_REVERSE_ITERATOR ordered_vector<Key, Compare>::
00160 rend() const {
00161   return _vector.rend();
00162 }
00163 
00164 ////////////////////////////////////////////////////////////////////
00165 //     Function: ordered_vector::operator []
00166 //       Access: Public
00167 //  Description: Returns the nth element.
00168 ////////////////////////////////////////////////////////////////////
00169 template<class Key, class Compare>
00170 INLINE TYPENAME ordered_vector<Key, Compare>::REFERENCE ordered_vector<Key, Compare>::
00171 operator [] (TYPENAME ordered_vector<Key, Compare>::SIZE_TYPE n) {
00172   return _vector[n];
00173 }
00174 
00175 ////////////////////////////////////////////////////////////////////
00176 //     Function: ordered_vector::operator []
00177 //       Access: Public
00178 //  Description: Returns the nth element.
00179 ////////////////////////////////////////////////////////////////////
00180 template<class Key, class Compare>
00181 INLINE TYPENAME ordered_vector<Key, Compare>::CONST_REFERENCE ordered_vector<Key, Compare>::
00182 operator [] (TYPENAME ordered_vector<Key, Compare>::SIZE_TYPE n) const {
00183   return _vector[n];
00184 }
00185 
00186 ////////////////////////////////////////////////////////////////////
00187 //     Function: ordered_vector::size
00188 //       Access: Public
00189 //  Description: Returns the number of elements in the ordered vector.
00190 ////////////////////////////////////////////////////////////////////
00191 template<class Key, class Compare>
00192 INLINE TYPENAME ordered_vector<Key, Compare>::SIZE_TYPE ordered_vector<Key, Compare>::
00193 size() const {
00194   return _vector.size();
00195 }
00196 
00197 ////////////////////////////////////////////////////////////////////
00198 //     Function: ordered_vector::max_size
00199 //       Access: Public
00200 //  Description: Returns the maximum number of elements that can
00201 //               possibly be stored in an ordered vector.
00202 ////////////////////////////////////////////////////////////////////
00203 template<class Key, class Compare>
00204 INLINE TYPENAME ordered_vector<Key, Compare>::SIZE_TYPE ordered_vector<Key, Compare>::
00205 max_size() const {
00206   return _vector.max_size();
00207 }
00208 
00209 ////////////////////////////////////////////////////////////////////
00210 //     Function: ordered_vector::empty
00211 //       Access: Public
00212 //  Description: Returns true if the ordered vector is empty, false
00213 //               otherwise.
00214 ////////////////////////////////////////////////////////////////////
00215 template<class Key, class Compare>
00216 INLINE bool ordered_vector<Key, Compare>::
00217 empty() const {
00218   return _vector.empty();
00219 }
00220 
00221 ////////////////////////////////////////////////////////////////////
00222 //     Function: ordered_vector::operator == 
00223 //       Access: Public
00224 //  Description: Returns true if the two ordered vectors are
00225 //               memberwise equivalent, false otherwise.
00226 ////////////////////////////////////////////////////////////////////
00227 template<class Key, class Compare>
00228 INLINE bool ordered_vector<Key, Compare>::
00229 operator == (const ordered_vector<Key, Compare> &other) const {
00230   return _vector == other._vector;
00231 }
00232 
00233 ////////////////////////////////////////////////////////////////////
00234 //     Function: ordered_vector::operator != 
00235 //       Access: Public
00236 //  Description: Returns true if the two ordered vectors are not
00237 //               memberwise equivalent, false if they are.
00238 ////////////////////////////////////////////////////////////////////
00239 template<class Key, class Compare>
00240 INLINE bool ordered_vector<Key, Compare>::
00241 operator != (const ordered_vector<Key, Compare> &other) const {
00242   return _vector != other._vector;
00243 }
00244 
00245 ////////////////////////////////////////////////////////////////////
00246 //     Function: ordered_vector::operator <
00247 //       Access: Public
00248 //  Description: Returns true if this ordered vector sorts
00249 //               lexicographically before the other one, false
00250 //               otherwise.
00251 ////////////////////////////////////////////////////////////////////
00252 template<class Key, class Compare>
00253 INLINE bool ordered_vector<Key, Compare>::
00254 operator < (const ordered_vector<Key, Compare> &other) const {
00255   return _vector < other._vector;
00256 }
00257 
00258 ////////////////////////////////////////////////////////////////////
00259 //     Function: ordered_vector::operator >
00260 //       Access: Public
00261 //  Description: Returns true if this ordered vector sorts
00262 //               lexicographically after the other one, false
00263 //               otherwise.
00264 ////////////////////////////////////////////////////////////////////
00265 template<class Key, class Compare>
00266 INLINE bool ordered_vector<Key, Compare>::
00267 operator > (const ordered_vector<Key, Compare> &other) const {
00268   return _vector > other._vector;
00269 }
00270 
00271 ////////////////////////////////////////////////////////////////////
00272 //     Function: ordered_vector::operator <=
00273 //       Access: Public
00274 //  Description: Returns true if this ordered vector sorts
00275 //               lexicographically before the other one or is
00276 //               equivalent, false otherwise.
00277 ////////////////////////////////////////////////////////////////////
00278 template<class Key, class Compare>
00279 INLINE bool ordered_vector<Key, Compare>::
00280 operator <= (const ordered_vector<Key, Compare> &other) const {
00281   return _vector <= other._vector;
00282 }
00283 
00284 ////////////////////////////////////////////////////////////////////
00285 //     Function: ordered_vector::operator >=
00286 //       Access: Public
00287 //  Description: Returns true if this ordered vector sorts
00288 //               lexicographically after the other one or is
00289 //               equivalent, false otherwise.
00290 ////////////////////////////////////////////////////////////////////
00291 template<class Key, class Compare>
00292 INLINE bool ordered_vector<Key, Compare>::
00293 operator >= (const ordered_vector<Key, Compare> &other) const {
00294   return _vector >= other._vector;
00295 }
00296 
00297 
00298 ////////////////////////////////////////////////////////////////////
00299 //     Function: ordered_vector::insert_unique
00300 //       Access: Public
00301 //  Description: Inserts the indicated key into the ordered vector, at
00302 //               the appropriate place.  If there is already an element
00303 //               sorting equivalent to the key in the vector, the new
00304 //               key is not inserted.
00305 //
00306 //               The return value is a pair, where the first component
00307 //               is the iterator referencing the new element (or the
00308 //               original element), and the second componet is true if
00309 //               the insert operation has taken place.
00310 ////////////////////////////////////////////////////////////////////
00311 template<class Key, class Compare>
00312 INLINE pair<TYPENAME ordered_vector<Key, Compare>::ITERATOR, bool> ordered_vector<Key, Compare>::
00313 insert_unique(const TYPENAME ordered_vector<Key, Compare>::VALUE_TYPE &key) {
00314   ITERATOR position = find_insert_position(begin(), end(), key);
00315 #ifdef NDEBUG
00316   pair<ITERATOR, bool> bogus_result(end(), false);
00317   nassertr(position >= begin() && position <= end(), bogus_result);
00318 #endif
00319 
00320   // If there's already an equivalent key in the vector, it's at
00321   // *(position - 1).
00322   if (position != begin() && !_compare(*(position - 1), key)) {
00323     pair<ITERATOR, bool> result(position - 1, false);
00324     nassertr(!_compare(key, *(position - 1)), result);
00325     return result;
00326   }
00327 
00328   ITERATOR result = _vector.insert(position, key);
00329   return pair<ITERATOR, bool>(result, true);
00330 }
00331 
00332 ////////////////////////////////////////////////////////////////////
00333 //     Function: ordered_vector::insert_nonunique
00334 //       Access: Public
00335 //  Description: Inserts the indicated key into the ordered vector, at
00336 //               the appropriate place.  If there are already elements
00337 //               sorting equivalent to the key in the vector, the new
00338 //               value is inserted following them.  
00339 
00340 //               The return value is the iterator referencing the new
00341 //               element.
00342 ////////////////////////////////////////////////////////////////////
00343 template<class Key, class Compare>
00344 INLINE TYPENAME ordered_vector<Key, Compare>::ITERATOR ordered_vector<Key, Compare>::
00345 insert_nonunique(const TYPENAME ordered_vector<Key, Compare>::VALUE_TYPE &key) {
00346   ITERATOR position = find_insert_position(begin(), end(), key);
00347   nassertr(position >= begin() && position <= end(), end());
00348 
00349   ITERATOR result = _vector.insert(position, key);
00350   return result;
00351 }
00352 
00353 
00354 ////////////////////////////////////////////////////////////////////
00355 //     Function: ordered_vector::erase, with iterator
00356 //       Access: Public
00357 //  Description: Removes the element indicated by the given iterator,
00358 //               and returns the next sequential iterator.
00359 ////////////////////////////////////////////////////////////////////
00360 template<class Key, class Compare>
00361 INLINE TYPENAME ordered_vector<Key, Compare>::ITERATOR ordered_vector<Key, Compare>::
00362 erase(TYPENAME ordered_vector<Key, Compare>::ITERATOR position) {
00363   SIZE_TYPE count = position - begin();
00364   _vector.erase(position);
00365   return begin() + count;
00366 }
00367 
00368 ////////////////////////////////////////////////////////////////////
00369 //     Function: ordered_vector::erase, with key
00370 //       Access: Public
00371 //  Description: Removes all elements matching the indicated key;
00372 //               returns the number of elements removed.
00373 ////////////////////////////////////////////////////////////////////
00374 template<class Key, class Compare>
00375 INLINE TYPENAME ordered_vector<Key, Compare>::SIZE_TYPE ordered_vector<Key, Compare>::
00376 erase(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) {
00377   pair<ITERATOR, ITERATOR> result = equal_range(key);
00378   SIZE_TYPE count = result.second - result.first;
00379   erase(result.first, result.second);
00380   return count;
00381 }
00382 
00383 ////////////////////////////////////////////////////////////////////
00384 //     Function: ordered_vector::erase, a range
00385 //       Access: Public
00386 //  Description: Removes all elements indicated by the given iterator
00387 //               range.
00388 ////////////////////////////////////////////////////////////////////
00389 template<class Key, class Compare>
00390 INLINE void ordered_vector<Key, Compare>::
00391 erase(TYPENAME ordered_vector<Key, Compare>::ITERATOR first,
00392       TYPENAME ordered_vector<Key, Compare>::ITERATOR last) {
00393   _vector.erase(first, last);
00394 }
00395 
00396 ////////////////////////////////////////////////////////////////////
00397 //     Function: ordered_vector::clear
00398 //       Access: Public
00399 //  Description: Removes all elements from the ordered vector.
00400 ////////////////////////////////////////////////////////////////////
00401 template<class Key, class Compare>
00402 INLINE void ordered_vector<Key, Compare>::
00403 clear() {
00404   _vector.erase(_vector.begin(), _vector.end());
00405 }
00406 
00407 ////////////////////////////////////////////////////////////////////
00408 //     Function: ordered_vector::find
00409 //       Access: Public
00410 //  Description: Searches for an element with the indicated key and
00411 //               returns its iterator if it is found, or end() if it
00412 //               is not.  If there are multiple elements matching the
00413 //               key, the particular iterator returned is not defined.
00414 ////////////////////////////////////////////////////////////////////
00415 template<class Key, class Compare>
00416 INLINE TYPENAME ordered_vector<Key, Compare>::ITERATOR ordered_vector<Key, Compare>::
00417 find(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) {
00418   return nci(r_find(begin(), end(), end(), key));
00419 }
00420 
00421 ////////////////////////////////////////////////////////////////////
00422 //     Function: ordered_vector::find
00423 //       Access: Public
00424 //  Description: Searches for an element with the indicated key and
00425 //               returns its iterator if it is found, or end() if it
00426 //               is not.  If there are multiple elements matching the
00427 //               key, the particular iterator returned is not defined.
00428 ////////////////////////////////////////////////////////////////////
00429 template<class Key, class Compare>
00430 INLINE TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR ordered_vector<Key, Compare>::
00431 find(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) const {
00432   return r_find(begin(), end(), end(), key);
00433 }
00434 
00435 ////////////////////////////////////////////////////////////////////
00436 //     Function: ordered_vector::find_particular
00437 //       Access: Public
00438 //  Description: Searches for a particular element and returns its
00439 //               iterator if it is found, or end() if it is not.
00440 //
00441 //               First, the Compare function is used to narrow down
00442 //               the range of elements the element might be located
00443 //               within; then the element is compared elementwise, via
00444 //               ==, until the exact matching element is found.  If
00445 //               multiple matches exist within the vector, the
00446 //               particular iterator returned is not defined.
00447 //
00448 //               The assumption is that == implies !Compare(a, b) and
00449 //               !Compare(b, a), but not necessarily the converse.
00450 ////////////////////////////////////////////////////////////////////
00451 template<class Key, class Compare>
00452 INLINE TYPENAME ordered_vector<Key, Compare>::ITERATOR ordered_vector<Key, Compare>::
00453 find_particular(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) {
00454   return nci(r_find_particular(begin(), end(), end(), key));
00455 }
00456 
00457 ////////////////////////////////////////////////////////////////////
00458 //     Function: ordered_vector::find_particular
00459 //       Access: Public
00460 //  Description: Searches for a particular element and returns its
00461 //               iterator if it is found, or end() if it is not.
00462 //
00463 //               First, the Compare function is used to narrow down
00464 //               the range of elements the element might be located
00465 //               within; then the element is compared elementwise, via
00466 //               ==, until the exact matching element is found.  If
00467 //               multiple matches exist within the vector, the
00468 //               particular iterator returned is not defined./
00469 ////////////////////////////////////////////////////////////////////
00470 template<class Key, class Compare>
00471 INLINE TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR ordered_vector<Key, Compare>::
00472 find_particular(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) const {
00473   return r_find_particular(begin(), end(), end(), key);
00474 }
00475 
00476 ////////////////////////////////////////////////////////////////////
00477 //     Function: ordered_vector::count
00478 //       Access: Public
00479 //  Description: Returns the number of elements that sort equivalent
00480 //               to the key that are in the vector.
00481 ////////////////////////////////////////////////////////////////////
00482 template<class Key, class Compare>
00483 INLINE TYPENAME ordered_vector<Key, Compare>::SIZE_TYPE ordered_vector<Key, Compare>::
00484 count(const key_type &key) const {
00485   return r_count(begin(), end(), key);
00486 }
00487 
00488 ////////////////////////////////////////////////////////////////////
00489 //     Function: ordered_vector::lower_bound
00490 //       Access: Public
00491 //  Description: Returns the iterator for the first element not less
00492 //               than key, or end() if all elements are less than key.
00493 ////////////////////////////////////////////////////////////////////
00494 template<class Key, class Compare>
00495 INLINE TYPENAME ordered_vector<Key, Compare>::ITERATOR ordered_vector<Key, Compare>::
00496 lower_bound(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) {
00497   return nci(r_lower_bound(begin(), end(), key));
00498 }
00499 
00500 ////////////////////////////////////////////////////////////////////
00501 //     Function: ordered_vector::lower_bound
00502 //       Access: Public
00503 //  Description: Returns the iterator for the first element not less
00504 //               than key, or end() if all elements are less than key.
00505 ////////////////////////////////////////////////////////////////////
00506 template<class Key, class Compare>
00507 INLINE TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR ordered_vector<Key, Compare>::
00508 lower_bound(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) const {
00509   return r_lower_bound(begin(), end(), key);
00510 }
00511 
00512 ////////////////////////////////////////////////////////////////////
00513 //     Function: ordered_vector::upper_bound
00514 //       Access: Public
00515 //  Description: Returns the iterator for the first element greater
00516 //               than key, or end() if no element is greater than
00517 //               key.
00518 ////////////////////////////////////////////////////////////////////
00519 template<class Key, class Compare>
00520 INLINE TYPENAME ordered_vector<Key, Compare>::ITERATOR ordered_vector<Key, Compare>::
00521 upper_bound(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) {
00522   return nci(r_upper_bound(begin(), end(), key));
00523 }
00524 
00525 ////////////////////////////////////////////////////////////////////
00526 //     Function: ordered_vector::upper_bound
00527 //       Access: Public
00528 //  Description: Returns the iterator for the first element greater
00529 //               than key, or end() if no element is greater than
00530 //               key.
00531 ////////////////////////////////////////////////////////////////////
00532 template<class Key, class Compare>
00533 INLINE TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR ordered_vector<Key, Compare>::
00534 upper_bound(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) const {
00535   return r_upper_bound(begin(), end(), key);
00536 }
00537 
00538 ////////////////////////////////////////////////////////////////////
00539 //     Function: ordered_vector::equal_range
00540 //       Access: Public
00541 //  Description: Returns the pair (lower_bound(key), upper_bound(key)).
00542 ////////////////////////////////////////////////////////////////////
00543 template<class Key, class Compare>
00544 INLINE pair<TYPENAME ordered_vector<Key, Compare>::ITERATOR, TYPENAME ordered_vector<Key, Compare>::ITERATOR> ordered_vector<Key, Compare>::
00545 equal_range(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) {
00546   pair<TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR, TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR> result;
00547   result = r_equal_range(begin(), end(), key);
00548   return pair<TYPENAME ordered_vector<Key, Compare>::ITERATOR, TYPENAME ordered_vector<Key, Compare>::ITERATOR>(nci(result.first), nci(result.second));
00549 }
00550 
00551 ////////////////////////////////////////////////////////////////////
00552 //     Function: ordered_vector::equal_range
00553 //       Access: Public
00554 //  Description: Returns the pair (lower_bound(key), upper_bound(key)).
00555 ////////////////////////////////////////////////////////////////////
00556 template<class Key, class Compare>
00557 INLINE pair<TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR, TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR> ordered_vector<Key, Compare>::
00558 equal_range(const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) const {
00559   return r_equal_range(begin(), end(), key);
00560 }
00561 
00562 ////////////////////////////////////////////////////////////////////
00563 //     Function: ordered_vector::swap
00564 //       Access: Public
00565 //  Description: Exchanges the contents of this vector and the other
00566 //               vector, in constant time (e.g., with a pointer swap).
00567 ////////////////////////////////////////////////////////////////////
00568 template<class Key, class Compare>
00569 INLINE void ordered_vector<Key, Compare>::
00570 swap(ordered_vector<Key, Compare> &copy) {
00571   _vector.swap(copy._vector);
00572 }
00573 
00574 ////////////////////////////////////////////////////////////////////
00575 //     Function: ordered_vector::reserve
00576 //       Access: Public
00577 //  Description: Informs the vector of a planned change in size;
00578 //               ensures that the capacity of the vector is greater
00579 //               than or equal to n.
00580 ////////////////////////////////////////////////////////////////////
00581 template<class Key, class Compare>
00582 INLINE void ordered_vector<Key, Compare>::
00583 reserve(TYPENAME ordered_vector<Key, Compare>::SIZE_TYPE n) {
00584   _vector.reserve(n);
00585 }
00586 
00587 ////////////////////////////////////////////////////////////////////
00588 //     Function: ordered_vector::sort_unique
00589 //       Access: Public
00590 //  Description: Ensures that the vector is properly sorted after a
00591 //               potentially damaging operation.  This should not
00592 //               normally need to be called, unless the user has
00593 //               written to the vector using the non-const iterators
00594 //               or has called push_back().
00595 //
00596 //               This flavor of sort also eliminates repeated
00597 //               elements.
00598 ////////////////////////////////////////////////////////////////////
00599 template<class Key, class Compare>
00600 INLINE void ordered_vector<Key, Compare>::
00601 sort_unique() {
00602   sort(begin(), end(), _compare);
00603   iterator new_end = unique(begin(), end(), EquivalentTest(_compare));
00604   erase(new_end, end());
00605 }
00606 
00607 ////////////////////////////////////////////////////////////////////
00608 //     Function: ordered_vector::sort_nonunique
00609 //       Access: Public
00610 //  Description: Ensures that the vector is properly sorted after a
00611 //               potentially damaging operation.  This should not
00612 //               normally need to be called, unless the user has
00613 //               written to the vector using the non-const iterators
00614 //               or has called push_back().
00615 ////////////////////////////////////////////////////////////////////
00616 template<class Key, class Compare>
00617 INLINE void ordered_vector<Key, Compare>::
00618 sort_nonunique() {
00619   sort(begin(), end(), _compare);
00620 }
00621 
00622 ////////////////////////////////////////////////////////////////////
00623 //     Function: ordered_vector::push_back
00624 //       Access: Public
00625 //  Description: Adds the new element to the end of the vector without
00626 //               regard for proper sorting.  This is a bad idea to do
00627 //               except to populate the vector the first time; be sure
00628 //               to call sort() after you have added all the elements.
00629 ////////////////////////////////////////////////////////////////////
00630 template<class Key, class Compare>
00631 INLINE void ordered_vector<Key, Compare>::
00632 push_back(const value_type &key) {
00633   _vector.push_back(key);
00634 }
00635 
00636 ////////////////////////////////////////////////////////////////////
00637 //     Function: ordered_vector::nci
00638 //       Access: Private
00639 //  Description: I.e. "non-const iterator".  This function is used to
00640 //               typecast a const iterator to a non-const iterator for
00641 //               easy definition of const vs. non-const flavors of
00642 //               some of these methods.
00643 ////////////////////////////////////////////////////////////////////
00644 template<class Key, class Compare>
00645 INLINE TYPENAME ordered_vector<Key, Compare>::ITERATOR ordered_vector<Key, Compare>::
00646 nci(TYPENAME ordered_vector<Key, Compare>::CONST_ITERATOR i) {
00647   return begin() + (i - begin());
00648 }
00649 
00650 ////////////////////////////////////////////////////////////////////
00651 //     Function: ordered_vector::find_insert_position
00652 //       Access: Private
00653 //  Description: Searches for the appropriate place in the ordered
00654 //               vector to insert the indicated key, and returns the
00655 //               corresponding iterator.
00656 ////////////////////////////////////////////////////////////////////
00657 template<class Key, class Compare>
00658 INLINE TYPENAME ordered_vector<Key, Compare>::ITERATOR ordered_vector<Key, Compare>::
00659 find_insert_position(TYPENAME ordered_vector<Key, Compare>::ITERATOR first,
00660                      TYPENAME ordered_vector<Key, Compare>::ITERATOR last,
00661                      const TYPENAME ordered_vector<Key, Compare>::KEY_TYPE &key) {
00662   ITERATOR result = r_find_insert_position(first, last, key);
00663   return result;
00664 }
00665 
00666 ////////////////////////////////////////////////////////////////////
00667 //     Function: ov_set::Constructor
00668 //       Access: Public
00669 //  Description: 
00670 ////////////////////////////////////////////////////////////////////
00671 template<class Key, class Compare>
00672 INLINE ov_set<Key, Compare>::
00673 ov_set(const Compare &compare) :
00674   ordered_vector<Key, Compare>(compare)
00675 {
00676 }
00677 
00678 ////////////////////////////////////////////////////////////////////
00679 //     Function: ov_set::Copy Constructor
00680 //       Access: Public
00681 //  Description: 
00682 ////////////////////////////////////////////////////////////////////
00683 template<class Key, class Compare>
00684 INLINE ov_set<Key, Compare>::
00685 ov_set(const ov_set<Key, Compare> &copy) :
00686   ordered_vector<Key, Compare>(copy)
00687 {
00688 }
00689 
00690 ////////////////////////////////////////////////////////////////////
00691 //     Function: ov_set::Copy Assignment Operator
00692 //       Access: Public
00693 //  Description: 
00694 ////////////////////////////////////////////////////////////////////
00695 template<class Key, class Compare>
00696 INLINE ov_set<Key, Compare> &ov_set<Key, Compare>::
00697 operator = (const ov_set<Key, Compare> &copy) {
00698   ordered_vector<Key, Compare>::operator = (copy);
00699   return *this;
00700 }
00701 
00702 ////////////////////////////////////////////////////////////////////
00703 //     Function: ov_set::insert
00704 //       Access: Public
00705 //  Description: Maps to insert_unique().
00706 ////////////////////////////////////////////////////////////////////
00707 template<class Key, class Compare>
00708 TYPENAME ov_set<Key, Compare>::ITERATOR ov_set<Key, Compare>::
00709 insert(TYPENAME ov_set<Key, Compare>::ITERATOR position, 
00710        const TYPENAME ov_set<Key, Compare>::VALUE_TYPE &key) {
00711   return ordered_vector<Key, Compare>::insert_unique(position, key);
00712 }
00713 
00714 ////////////////////////////////////////////////////////////////////
00715 //     Function: ov_set::insert
00716 //       Access: Public
00717 //  Description: Maps to insert_unique().
00718 ////////////////////////////////////////////////////////////////////
00719 template<class Key, class Compare>
00720 INLINE pair<TYPENAME ov_set<Key, Compare>::ITERATOR, bool> ov_set<Key, Compare>::
00721 insert(const TYPENAME ov_set<Key, Compare>::VALUE_TYPE &key) {
00722   return ordered_vector<Key, Compare>::insert_unique(key);
00723 }
00724 
00725 ////////////////////////////////////////////////////////////////////
00726 //     Function: ov_set::sort
00727 //       Access: Public
00728 //  Description: Maps to sort_unique().
00729 ////////////////////////////////////////////////////////////////////
00730 template<class Key, class Compare>
00731 INLINE void ov_set<Key, Compare>::
00732 sort() {
00733   ordered_vector<Key, Compare>::sort_unique();
00734 }
00735 
00736 ////////////////////////////////////////////////////////////////////
00737 //     Function: ov_set::verify_list
00738 //       Access: Public
00739 //  Description: Maps to verify_list_unique().
00740 ////////////////////////////////////////////////////////////////////
00741 template<class Key, class Compare>
00742 INLINE bool ov_set<Key, Compare>::
00743 verify_list() const {
00744   return ordered_vector<Key, Compare>::verify_list_unique();
00745 }
00746 
00747 ////////////////////////////////////////////////////////////////////
00748 //     Function: ov_multiset::Constructor
00749 //       Access: Public
00750 //  Description: 
00751 ////////////////////////////////////////////////////////////////////
00752 template<class Key, class Compare>
00753 INLINE ov_multiset<Key, Compare>::
00754 ov_multiset(const Compare &compare) :
00755   ordered_vector<Key, Compare>(compare)
00756 {
00757 }
00758 
00759 ////////////////////////////////////////////////////////////////////
00760 //     Function: ov_multiset::Copy Constructor
00761 //       Access: Public
00762 //  Description: 
00763 ////////////////////////////////////////////////////////////////////
00764 template<class Key, class Compare>
00765 INLINE ov_multiset<Key, Compare>::
00766 ov_multiset(const ov_multiset<Key, Compare> &copy) :
00767   ordered_vector<Key, Compare>(copy)
00768 {
00769 }
00770 
00771 ////////////////////////////////////////////////////////////////////
00772 //     Function: ov_multiset::Copy Assignment Operator
00773 //       Access: Public
00774 //  Description: 
00775 ////////////////////////////////////////////////////////////////////
00776 template<class Key, class Compare>
00777 INLINE ov_multiset<Key, Compare> &ov_multiset<Key, Compare>::
00778 operator = (const ov_multiset<Key, Compare> &copy) {
00779   ordered_vector<Key, Compare>::operator = (copy);
00780   return *this;
00781 }
00782 
00783 ////////////////////////////////////////////////////////////////////
00784 //     Function: ov_multiset::insert
00785 //       Access: Public
00786 //  Description: Maps to insert_nonunique().
00787 ////////////////////////////////////////////////////////////////////
00788 template<class Key, class Compare>
00789 TYPENAME ov_multiset<Key, Compare>::ITERATOR ov_multiset<Key, Compare>::
00790 insert(TYPENAME ov_multiset<Key, Compare>::ITERATOR position, 
00791        const TYPENAME ov_multiset<Key, Compare>::VALUE_TYPE &key) {
00792   return ordered_vector<Key, Compare>::insert_nonunique(position, key);
00793 }
00794 
00795 ////////////////////////////////////////////////////////////////////
00796 //     Function: ov_multiset::insert
00797 //       Access: Public
00798 //  Description: Maps to insert_nonunique().
00799 ////////////////////////////////////////////////////////////////////
00800 template<class Key, class Compare>
00801 INLINE TYPENAME ov_multiset<Key, Compare>::ITERATOR ov_multiset<Key, Compare>::
00802 insert(const TYPENAME ov_multiset<Key, Compare>::VALUE_TYPE &key) {
00803   return ordered_vector<Key, Compare>::insert_nonunique(key);
00804 }
00805 
00806 ////////////////////////////////////////////////////////////////////
00807 //     Function: ov_multiset::sort
00808 //       Access: Public
00809 //  Description: Maps to sort_nonunique().
00810 ////////////////////////////////////////////////////////////////////
00811 template<class Key, class Compare>
00812 INLINE void ov_multiset<Key, Compare>::
00813 sort() {
00814   ordered_vector<Key, Compare>::sort_nonunique();
00815 }
00816 
00817 ////////////////////////////////////////////////////////////////////
00818 //     Function: ov_multiset::verify_list
00819 //       Access: Public
00820 //  Description: Maps to verify_list_nonunique().
00821 ////////////////////////////////////////////////////////////////////
00822 template<class Key, class Compare>
00823 INLINE bool ov_multiset<Key, Compare>::
00824 verify_list() const {
00825   return ordered_vector<Key, Compare>::verify_list_nonunique();
00826 }

Generated on Fri May 2 00:38:29 2003 for Panda by doxygen1.3