Wm4TSmallUnorderedSet.h

Go to the documentation of this file.
00001 // Wild Magic Source Code
00002 // David Eberly
00003 // http://www.geometrictools.com
00004 // Copyright (c) 1998-2008
00005 //
00006 // This library is free software; you can redistribute it and/or modify it
00007 // under the terms of the GNU Lesser General Public License as published by
00008 // the Free Software Foundation; either version 2.1 of the License, or (at
00009 // your option) any later version.  The license is available for reading at
00010 // either of the locations:
00011 //     http://www.gnu.org/copyleft/lgpl.html
00012 //     http://www.geometrictools.com/License/WildMagicLicense.pdf
00013 //
00014 // Version: 4.0.1 (2007/02/25)
00015 
00016 #ifndef WM4TSMALLUNORDEREDSET_H
00017 #define WM4TSMALLUNORDEREDSET_H
00018 
00019 #include "Wm4FoundationLIB.h"
00020 
00021 // This template class is for unordered sets of objects.  The intent is that
00022 // the sets are not too large.  If you do not plan on searching the set and
00023 // you know that the elements to be added are unique, then the size of the
00024 // set is irrelevant since a member function is provided that inserts an
00025 // element without checking to see if one already exists.
00026 //
00027 // The class T is either native data or is class data that has the following
00028 // member functions:
00029 //   T::T ()
00030 //   T::T (const T&);
00031 //   T& T::operator= (const T&)
00032 
00033 namespace Wm4
00034 {
00035 
00036 template <class T>
00037 class TSmallUnorderedSet
00038 {
00039 public:
00040     // construction and destruction
00041     TSmallUnorderedSet ();
00042     TSmallUnorderedSet (int iMaxQuantity, int iGrowBy);
00043     TSmallUnorderedSet (const TSmallUnorderedSet& rkSet);
00044     ~TSmallUnorderedSet ();
00045 
00046     // assignment
00047     TSmallUnorderedSet& operator= (const TSmallUnorderedSet& rkSet);
00048 
00049     // member access
00050     int GetMaxQuantity () const;
00051     int GetGrowBy () const;
00052     int GetQuantity () const;
00053     T* GetElements ();
00054     const T* GetElements () const;
00055     T& operator[] (int i);
00056     const T& operator[] (int i) const;
00057 
00058     // insertion, removal, searching
00059     bool Insert (const T& rkElement);
00060     void InsertNoCheck (const T& rkElement);
00061     bool Remove (const T& rkElement);
00062     bool Exists (const T& rkElement);
00063 
00064     // make empty set, keep quantity and growth parameters
00065     void Clear ();
00066 
00067     // make empty set, reallocate using new quantity and growth parameters
00068     void Clear (int iMaxQuantity, int iGrowBy);
00069 
00070 private:
00071     int m_iQuantity, m_iMaxQuantity, m_iGrowBy;
00072     T* m_atElement;
00073 };
00074 
00075 #include "Wm4TSmallUnorderedSet.inl"
00076 
00077 }
00078 
00079 #endif

Generated on Fri Feb 13 13:58:10 2009 for meshmorph by  doxygen 1.5.1