library: libCore
#include "TMap.h"

TMap


class description - source file - inheritance tree (.pdf)

class TMap : public TCollection

Inheritance Chart:
TObject
<-
TCollection
<-
TMap

    public:
TMap(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0) virtual ~TMap() virtual void Add(TObject* obj) void Add(TObject* key, TObject* value) Float_t AverageCollisions() const Int_t Capacity() const static TClass* Class() virtual void Clear(Option_t* option = "") Int_t Collisions(const char* keyname) const Int_t Collisions(TObject* key) const virtual void Delete(Option_t* option = "") void DeleteAll() void DeleteKeys() void DeleteValues() virtual TObject* FindObject(const char* keyname) const virtual TObject* FindObject(const TObject* key) const virtual TObject** GetObjectRef(const TObject* obj) const const THashTable* GetTable() const TObject* GetValue(const char* keyname) const TObject* GetValue(const TObject* key) const virtual TClass* IsA() const virtual TIterator* MakeIterator(Bool_t dir = kIterForward) const virtual void Print(Option_t* wildcard = "") const virtual void Print(Option_t* wildcard, Option_t* option) const void Rehash(Int_t newCapacity, Bool_t checkObjValidity = kTRUE) virtual TObject* Remove(TObject* key) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members

    private:
THashTable* fTable Hash table used to store TPair's

Class Description

                                                                      
 TMap                                                                 
                                                                      
 TMap implements an associative array of (key,value) pairs using a    
 THashTable for efficient retrieval (therefore TMap does not conserve 
 the order of the entries). The hash value is calculated              
 using the value returned by the keys Hash() function. Both key and   
 value need to inherit from TObject.                                  
/* */
                                                                      


TMap(Int_t capacity, Int_t rehashlevel)
 TMap ctor. See THashTable for a description of the arguments.

~TMap()
 TMap dtor. Objects are not deleted unless the TMap is the
 owner (set via SetOwner()).

void Add(TObject *)
 This function may not be used (but we need to provide it since it is
 a pure virtual in TCollection). Use Add(key,value) instead.

void Add(TObject *key, TObject *value)
 Add a (key,value) pair to the map.

Float_t AverageCollisions() const
 Return the ratio of entries vs occupied slots.

Int_t Capacity() const
 Return number of slots in the hashtable. Use GetSize() to get the
 number of objects stored in the TMap.

void Clear(Option_t *option)
 Remove all (key,value) pairs from the map but DO NOT delete the keys
 and/or values. Key objects are not deleted unless the TMap is the
 owner (set via SetOwner()). To delete only the value objects call
 DeleteValues() and to delete both keys and values use DeleteAll().

Int_t Collisions(const char *keyname) const
 Returns the number of collisions for a key with a certain name
 (i.e. number of objects in same slot in the hash table, i.e. length
 of linked list).

Int_t Collisions(TObject *key) const
 Returns the number of collisions for a key (i.e. number of objects
 in same slot in the hash table, i.e. length of linked list).

void Delete(Option_t *option)
 Remove all (key,value) pairs from the map AND delete the keys
 when they are allocated on the heap.

void DeleteValues()
 Remove all (key,value) pairs from the map AND delete the values
 when they are allocated on the heap.

void DeleteAll()
 Remove all (key,value) pairs from the map AND delete the keys AND
 values when they are allocated on the heap.

TObject* FindObject(const char *keyname) const
 Check if a (key,value) pair exists with keyname as name of the key.
 Returns a TPair* (need to downcast from TObject). Use Key() and
 Value() to get the pointers to the key and value, respectively.
 Returns 0 if not found.

TObject* FindObject(const TObject *key) const
 Check if a (key,value) pair exists with key as key.
 Returns a TPair* (need to downcast from TObject). Use Key() and
 Value() to get the pointers to the key and value, respectively.
 Returns 0 if not found.

TObject* GetValue(const char *keyname) const
 Returns a pointer to the value associated with keyname as name of the key.

TObject* GetValue(const TObject *key) const
 Returns a pointer to the value associated with key.

TIterator* MakeIterator(Bool_t dir) const
 Create an iterator for TMap.

void Print(Option_t *wildcard) const
 Print all objects in this collection.
 Wildcarding is supported, e.g. wildcard="xxx*" prints only objects
 with names matching xxx*.

void Print(Option_t *wildcard, Option_t *option) const
 Print all objects in this collection, passing option to the
 objects Print() method.
 Wildcarding is supported, e.g. wildcard="xxx*" prints only objects
 with names matching xxx*.

void Rehash(Int_t newCapacity, Bool_t checkObjValidity)
 Rehash the underlaying THashTable (see THashTable::Rehash()).

TObject* Remove(TObject *key)
 Remove the (key,value) pair with key from the map. Returns the key
 object or 0 in case key was not found.

void Streamer(TBuffer &b)
 Stream all key/value pairs in the map to or from the I/O buffer.



Inline Functions


                     void DeleteKeys()
                TObject** GetObjectRef(const TObject* obj) const
        const THashTable* GetTable() const
                  TClass* Class()
                  TClass* IsA() const
                     void ShowMembers(TMemberInspector& insp, char* parent)
                     void StreamerNVirtual(TBuffer& b)


Author: Fons Rademakers 12/11/95
Last update: root/cont:$Name: $:$Id: TMap.cxx,v 1.13 2004/10/13 15:30:22 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.