csutil/strhash.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2002 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_STRHASH_H__ 00020 #define __CS_STRHASH_H__ 00021 00022 #include "csextern.h" 00023 #include "csutil/hash.h" 00024 #include "csutil/mempool.h" 00025 #include "iutil/strset.h" 00026 00038 class CS_CRYSTALSPACE_EXPORT csStringHash 00039 { 00040 private: 00041 typedef csHash<csStringID, char const*> HashType; 00042 HashType registry; 00043 csMemoryPool pool; 00044 00045 void Copy(csStringHash const&); 00046 00047 public: 00048 typedef HashType::ConstGlobalIterator GlobalIterator; 00049 00050 public: 00052 csStringHash (size_t size = 23); 00054 csStringHash (csStringHash const& h) { Copy(h); } 00056 ~csStringHash (); 00058 csStringHash& operator=(csStringHash const& h) { Copy(h); return *this; } 00059 00079 const char* Register (const char* s, csStringID id = 0); 00080 00086 csStringID Request (const char* s) const; 00087 00098 const char* Request (csStringID id) const; 00099 00105 bool Contains(char const* s) const 00106 { return Request(s) != csInvalidStringID; } 00107 00116 bool Contains(csStringID id) const 00117 { return Request(id) != 0; } 00118 00123 bool Delete(char const* s); 00124 00131 bool Delete(csStringID id); 00132 00136 void Empty (); 00137 00142 /*CS_DEPRECATED_METHOD("Use Empty() instead.")*/ 00143 void Clear () 00144 { Empty(); } 00145 00147 size_t GetSize () const 00148 { return registry.GetSize (); } 00149 00155 bool IsEmpty() const 00156 { return GetSize() == 0; } 00157 00163 GlobalIterator GetIterator () const 00164 { return registry.GetIterator(); } 00165 }; 00166 00167 #endif // __CS_STRHASH_H__
Generated for Crystal Space by doxygen 1.4.7