csutil/strset.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2001 by Martin Geisse <[email protected]> 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_STRSET_H__ 00020 #define __CS_STRSET_H__ 00021 00022 #include "csextern.h" 00023 #include "csutil/strhash.h" 00024 00039 class CS_CRYSTALSPACE_EXPORT csStringSet 00040 { 00041 private: 00042 csStringHash registry; 00043 csHash<const char*, csStringID> reverse; // ID to string mapping. 00044 csStringID next_id; 00045 00046 void Copy(csStringSet const&); 00047 00048 public: 00049 typedef csStringHash::GlobalIterator GlobalIterator; 00050 00051 public: 00053 csStringSet (size_t size = 23); 00055 csStringSet (csStringSet const& s) { Copy(s); } 00057 ~csStringSet (); 00059 csStringSet& operator=(csStringSet const& s) { Copy(s); return *this; } 00060 00067 csStringID Request (const char*); 00068 00074 char const* Request (csStringID) const; 00075 00079 bool Contains(char const*) const; 00080 00086 bool Contains(csStringID id) const 00087 { return Request(id) != 0; } 00088 00093 bool Delete(char const* s); 00094 00099 bool Delete(csStringID id); 00100 00105 void Empty (); 00106 00111 /*CS_DEPRECATED_METHOD("Use Empty() instead.")*/ 00112 void Clear () 00113 { Empty(); } 00114 00116 size_t GetSize () const 00117 { return registry.GetSize (); } 00118 00124 bool IsEmpty() const 00125 { return GetSize() == 0; } 00126 00132 GlobalIterator GetIterator () const 00133 { return registry.GetIterator(); } 00134 }; 00135 00136 #endif // __CS_STRSET_H__
Generated for Crystal Space by doxygen 1.4.7