00001 #ifndef _GEMFIRE_HASHSETOFSHAREDBASE_HPP_ 00002 #define _GEMFIRE_HASHSETOFSHAREDBASE_HPP_ 00003 00004 00005 /*========================================================================= 00006 * (c) Copyright 2002-2007, GemStone Systems, Inc. All Rights Reserved. 00007 * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 00008 *======================================================================== 00009 */ 00010 00011 #include "gfcpp_globals.hpp" 00012 #include "SharedPtr.hpp" 00013 #include "HashFunction.hpp" 00014 #ifdef BUILD_CPPCACHE 00015 #include <hash_set> 00016 #endif 00017 00018 00022 namespace gemfire 00023 { 00024 00025 #ifdef BUILD_CPPCACHE 00026 typedef std::hash_set< SharedBasePtr, HashSB, EqualToSB > HSofSBP; 00027 typedef HSofSBP::const_iterator HSofSBPIterator; 00028 #else 00029 class HSofSBP; 00030 class HSofSBPIterator; 00031 #endif 00032 00033 00036 class CPPCACHE_EXPORT HashSetOfSharedBase 00037 { 00038 private: 00039 00040 HSofSBP* m_stdHashSet; 00041 00042 // Never defined. 00043 HashSetOfSharedBase( ); 00044 00045 00046 public: 00047 00049 class CPPCACHE_EXPORT Iterator 00050 { 00051 private: 00052 00053 const HashSetOfSharedBase& m_set; 00054 HSofSBPIterator* m_iter; 00055 00056 Iterator( const HSofSBPIterator& iter, 00057 const HashSetOfSharedBase& set ); 00058 00059 // Never defined. 00060 Iterator( ); 00061 00062 00063 public: 00064 00065 Iterator( const Iterator& other ); 00066 00067 const SharedBasePtr operator * ( ) const; 00068 00069 bool isEnd( ) const; 00070 00071 Iterator& operator ++ ( ); 00072 00073 void operator ++ ( int ); 00074 00075 bool operator == ( const Iterator& other ) const; 00076 00077 bool operator != ( const Iterator& other ) const; 00078 00079 void reset( ); 00080 00081 ~Iterator( ); 00082 00083 00084 friend class HashSetOfSharedBase; 00085 }; 00086 00087 00089 size_t size( ) const; 00090 00092 size_t max_size( ) const; 00093 00095 bool empty( ) const; 00096 00098 size_t bucket_count( ) const; 00099 00101 void resize( size_t n ); 00102 00104 void swap( HashSetOfSharedBase& other ); 00105 00107 bool insert( const SharedBasePtr& k ); 00108 00110 size_t erase( const SharedBasePtr& k ); 00111 00113 void clear( ); 00114 00116 bool contains( const SharedBasePtr& k ) const; 00117 00119 size_t count( const SharedBasePtr& k ) const; 00120 00122 Iterator begin( ) const; 00123 00125 Iterator end( ) const; 00126 00128 HashSetOfSharedBase& operator = ( const HashSetOfSharedBase& other ); 00129 00133 HashSetOfSharedBase( const Hasher h, const EqualTo k ); 00134 00138 HashSetOfSharedBase( size_t n, const Hasher h, const EqualTo k ); 00139 00141 HashSetOfSharedBase( const HashSetOfSharedBase& other ); 00142 00144 ~HashSetOfSharedBase( ); 00145 }; 00146 00147 } 00148 00149 00150 #endif