Polaris: Dictionary< T > Class Template Reference

Dictionary< T > Class Template Reference

file Dictionary.h A hashtable based on strings More...

#include <Dictionary.h>

Inheritance diagram for Dictionary< T >:

Inheritance graph
[legend]
List of all members.

Public Member Functions

INLINE Dictionary ()
INLINE Dictionary (const Dictionary< T > &dict)
INLINE Dictionary< T > & operator= (const Dictionary< T > &dict)
virtual INLINE ~Dictionary ()
 virtual Dictionary<T> *clone() const;
virtual INLINE void del (const char *tag)
virtual INLINE void ins (T *elem)
virtual INLINE void ins (T *elem, int replace_if_already_exists)
 Insert item into the dictionary.
virtual INLINE const T * find_ref (const char *tag) const
virtual INLINE T * find_ref (const char *tag)
virtual INLINE const T * find (const char *tag) const
virtual INLINE T * find (const char *tag)
virtual INLINE const T & operator[] (const char *tag) const
virtual INLINE T & operator[] (const char *tag)
virtual INLINE T * grab (const char *tag)
 Remove and return (does NOT delete) the item in the dictionary which has this tag.
virtual INLINE const T * arb_ref () const
virtual INLINE T * arb_ref ()
 Returns pointer to arbitrary element (or 0 if dictionary is empty).
virtual INLINE T * grab_arb ()
 Removes and returns pointer to arbitrary element (or returns 0 if dictionary is empty).
virtual INLINE void print (ostream &o) const
 Print the elements of the dictionary.
virtual INLINE void rename (const char *tag, const char *new_tag)
 Rename the member of this class whose tag is 'tag' to the new tag 'new_tag' (and automatically reindex it).

Friends

class Definition

Detailed Description

template<class T>
class Dictionary< T >

file Dictionary.h A hashtable based on strings

C Polaris

See also:
Dictionary/Data.h

Dictionary.cc

Dictionary.h

Description

The Dictionary is used to store objects which can be retrieved based upon a string tag. In order to guarnatee that the objects in the Dictionary have the appropriate fields, the the class used in the Dictionary template (T) must be derived from Definition.

Definition at line 35 of file Dictionary.h.


Constructor & Destructor Documentation

template<class T>
INLINE Dictionary< T >::Dictionary  ) 
 

Definition at line 96 of file Dictionary.h.

References register_instance().

template<class T>
INLINE Dictionary< T >::Dictionary const Dictionary< T > &  dict  ) 
 

Definition at line 105 of file Dictionary.h.

References register_instance().

template<class T>
INLINE Dictionary< T >::~Dictionary  )  [virtual]
 

virtual Dictionary<T> *clone() const;

Definition at line 125 of file Dictionary.h.

References unregister_instance().


Member Function Documentation

template<class T>
INLINE Dictionary< T > & Dictionary< T >::operator= const Dictionary< T > &  dict  ) 
 

Definition at line 116 of file Dictionary.h.

References Database< S, T >::operator=().

Referenced by CommonBlockDict::CommonBlockDict(), EquivalenceDict::EquivalenceDict(), EquivalenceDict::operator=(), and CommonBlockDict::operator=().

template<class T>
INLINE void Dictionary< T >::del const char *  tag  )  [virtual]
 

Reimplemented in EquivalenceDict.

Definition at line 156 of file Dictionary.h.

References Database< S, T >::del().

Referenced by Symtab::del(), StmtList::del(), Dictionary< T >::ins(), main(), StmtList::retag(), and StmtList::split_elseif().

template<class T>
INLINE void Dictionary< T >::ins T *  elem  )  [virtual]
 

Definition at line 134 of file Dictionary.h.

Referenced by StmtList::convert(), ProgramUnit::create_program_unit(), external_program_unit(), Symtab::ins(), main(), move_saved_vars(), Symtab::operator=(), read_pu(), Dictionary< T >::rename(), StmtList::retag(), StmtList::split_elseif(), store_pu(), Symtab::Symtab(), and Variable_set_new().

template<class T>
INLINE void Dictionary< T >::ins T *  elem,
int  replace_if_already_exists
[virtual]
 

Insert item into the dictionary.

The meaning of the replace_if_already_exists is: replace_if_already_exists != 0 : If an item already exists in the dictionary with the same tag as item, the old item is deleted and is replaced by item. replace_if_already_exists == 0 : If an item already exists in the dictionary with the same tag as item, an error message is displayed and the program is aborted.

Definition at line 141 of file Dictionary.h.

References Dictionary< T >::del(), Database< S, T >::ins(), and ProtoDatabase< String, T >::member().

template<class T>
INLINE const T * Dictionary< T >::find_ref const char *  tag  )  const [virtual]
 

Definition at line 165 of file Dictionary.h.

References ProtoDatabase< S, T >::find_ref().

Referenced by Dictionary< T >::arb_ref(), StmtList::convert(), external_program_unit(), Dictionary< T >::find(), Symtab::find_ref(), StmtList::find_ref(), main(), Symtab::operator[](), Dictionary< T >::operator[](), StmtList::retag(), and store_pu().

template<class T>
INLINE T * Dictionary< T >::find_ref const char *  tag  )  [virtual]
 

Definition at line 173 of file Dictionary.h.

References ProtoDatabase< S, T >::find_ref().

template<class T>
INLINE const T * Dictionary< T >::find const char *  tag  )  const [virtual]
 

Definition at line 181 of file Dictionary.h.

References Dictionary< T >::find_ref().

template<class T>
INLINE T * Dictionary< T >::find const char *  tag  )  [virtual]
 

Definition at line 188 of file Dictionary.h.

References Dictionary< T >::find_ref().

template<class T>
INLINE const T & Dictionary< T >::operator[] const char *  tag  )  const [virtual]
 

Definition at line 195 of file Dictionary.h.

References dict_abort(), and Dictionary< T >::find_ref().

template<class T>
INLINE T & Dictionary< T >::operator[] const char *  tag  )  [virtual]
 

Definition at line 205 of file Dictionary.h.

References dict_abort(), and Dictionary< T >::find_ref().

template<class T>
INLINE T * Dictionary< T >::grab const char *  tag  )  [virtual]
 

Remove and return (does NOT delete) the item in the dictionary which has this tag.

Returns 0 if none was found

Definition at line 215 of file Dictionary.h.

References Database< S, T >::grab().

Referenced by Symtab::grab(), Dictionary< T >::grab_arb(), Dictionary< T >::rename(), and retrieve_pu().

template<class T>
INLINE const T * Dictionary< T >::arb_ref  )  const [virtual]
 

Definition at line 224 of file Dictionary.h.

References TypedBaseMap< S, T >::arb_key_ref(), and Dictionary< T >::find_ref().

Referenced by Dictionary< T >::grab_arb().

template<class T>
INLINE T * Dictionary< T >::arb_ref  )  [virtual]
 

Returns pointer to arbitrary element (or 0 if dictionary is empty).

Definition at line 236 of file Dictionary.h.

References TypedBaseMap< S, T >::arb_key_ref(), and Dictionary< T >::find_ref().

template<class T>
INLINE T * Dictionary< T >::grab_arb  )  [virtual]
 

Removes and returns pointer to arbitrary element (or returns 0 if dictionary is empty).

Definition at line 248 of file Dictionary.h.

References Dictionary< T >::arb_ref(), and Dictionary< T >::grab().

template<class T>
INLINE void Dictionary< T >::print ostream &  o  )  const [virtual]
 

Print the elements of the dictionary.

It invokes a non-virtual member function to print a representation of the data structure at this level of the Collection hierarchy, and, since it is not a class member function, it must be explicitly instantiated before use.

Reimplemented from Database< String, T >.

Definition at line 273 of file Dictionary.h.

References Database< S, T >::print().

template<class T>
INLINE void Dictionary< T >::rename const char *  tag,
const char *  new_tag
[virtual]
 

Rename the member of this class whose tag is 'tag' to the new tag 'new_tag' (and automatically reindex it).

An error occurs if there is not item in the dictionary with the tag 'tag' OR if there is already an item in the dictionary with the tag 'new_tag'.

Definition at line 260 of file Dictionary.h.

References Dictionary< T >::grab(), and Dictionary< T >::ins().

Referenced by Symtab::rename().


Friends And Related Function Documentation

template<class T>
friend class Definition [friend]
 

Definition at line 36 of file Dictionary.h.


The documentation for this class was generated from the following file:
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:07:11 2005