TMap


class description - source file - inheritance tree

class TMap : public TCollection


    public:
TMap TMap(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0) virtual void ~TMap() void Add(TObject* key, TObject* value) virtual void Add(TObject* obj) Float_t AverageCollisions() const Int_t Capacity() const 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() virtual TObject* FindObject(TObject* key) const virtual TObject* FindObject(const char* keyname) const TObject* GetValue(TObject* key) const virtual TClass* IsA() const virtual TIterator* MakeIterator(Bool_t dir = kIterForward) 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)

Data Members

private:
THashTable* fTable Hash table used to store TAssociation'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.

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.

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 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 TAssoc* (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(TObject *key) const
 Check if a (key,value) pair exists with key as key.
 Returns a TAssoc* (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(TObject *key) const
 Returns a pointer to the value associated with key.

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

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.

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



Inline Functions


            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)


Author: Fons Rademakers 12/11/95
Last update: 2.23/12 26/01/2000 09.57.11 by Rene Brun
Copyright (c) 1995-1999, The ROOT System, All rights reserved. *


ROOT page - Class index - 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.