Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

idep_nameindexmap.h

Go to the documentation of this file.
00001 // idep_nameindexmap.h
00002 #ifndef INCLUDED_IDEP_NAMEINDEXMAP
00003 #define INCLUDED_IDEP_NAMEINDEXMAP
00004 
00005 // This component defines 1 fully insulated class:
00006 //   idep_NameIndexMap: efficient two-way mapping between strings and indices
00007 
00008 #include <iosfwd>
00009 
00010 class idep_NameIndexMap_i;
00011 class idep_NameIndexMap {
00012     idep_NameIndexMap_i *d_this;
00013 
00014   private:
00015     idep_NameIndexMap(const idep_NameIndexMap&);            // not implemented
00016     idep_NameIndexMap& operator=(const idep_NameIndexMap&); // not implemented
00017 
00018   public:
00019     // CREATORS
00020     idep_NameIndexMap(int maxEntriesHint = 0); 
00021         // Create a new mapping; optionally specify the expected number of
00022         // entires.  By default, a moderately large hash table will be created.
00023     ~idep_NameIndexMap();                                     
00024 
00025     // MANIPULATORS
00026     int add(const char* name);
00027         // Add a name to the mapping and return its index only if the name is
00028         // not already present; otherwise return -1.
00029 
00030     int entry(const char* name);
00031         // Add a name to the table if necessary; always return a valid index.
00032         // Note: entry() is usually more efficient than lookup() followed by 
00033         // an occasional add().
00034 
00035     // ACCESSORS
00036     const char *operator[](int) const;
00037         // Return the name associated with the specified index or 0 if the
00038         // specified index is out of the range [0 .. N], where N = length - 1.
00039 
00040     int length() const;
00041         // Return the number of unique names in this mapping.
00042 
00043     int lookup(const char *name) const;
00044         // Return the index of the specified name, or -1 if not found.
00045 };
00046 
00047 std::ostream& operator<<(std::ostream& out, const idep_NameIndexMap& map);
00048         // Print the logical contents of this mapping to the specified
00049         // output stream (out) in some reasonable format.
00050         
00051 #endif
00052 

Generated on Mon Feb 15 11:06:48 2010 for loon by  doxygen 1.3.9.1