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

panda/src/express/test_ordered_vector.cxx

Go to the documentation of this file.
00001 // Filename: test_ordered_vector.cxx
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 #include "ordered_vector.h"
00020 
00021 typedef ov_multiset<int> myvec;
00022 
00023 void
00024 search(myvec &v, int element) {
00025   pair<myvec::const_iterator, myvec::const_iterator> result;
00026   
00027   result = v.equal_range(element);
00028   size_t count = v.count(element);
00029 
00030   cerr << element << " bounded by " << result.first - v.begin() << " and " 
00031        << result.second - v.begin() << "; " << count << " total.\n";
00032 }
00033 
00034 int
00035 main(int argc, char *argv[]) {
00036   myvec a, b;
00037 
00038   myvec::iterator mi;
00039   mi = a.insert(a.end(), 3);
00040   mi = a.insert(mi, 5);
00041   mi = a.insert(mi, 4);
00042   mi = a.insert(mi, 4);
00043   mi = a.insert(mi, 2);
00044   mi = a.insert(mi, 5);
00045   mi = a.insert(mi, 2);
00046 
00047   a.swap(b);
00048 
00049   cerr << b.size() << " elements:\n";
00050 
00051   myvec::iterator bi;
00052   for (bi = b.begin(); bi != b.end(); ++bi) {
00053     cerr << *bi << " ";
00054   }
00055   cerr << "\n";
00056 
00057   search(b, 1);
00058   search(b, 2);
00059   search(b, 3);
00060   search(b, 4);
00061   search(b, 5);
00062   search(b, 6);
00063 
00064   cerr << "Removing 4:\n";
00065   size_t count = b.erase(4);
00066   cerr << "Removed " << count << "\n";
00067 
00068 
00069   cerr << b.size() << " elements:\n";
00070 
00071   for (bi = b.begin(); bi != b.end(); ++bi) {
00072     cerr << *bi << " ";
00073   }
00074   cerr << "\n";
00075 
00076   search(b, 1);
00077   search(b, 2);
00078   search(b, 3);
00079   search(b, 4);
00080   search(b, 5);
00081   search(b, 6);
00082 
00083   return (0);
00084 }

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