class TMap: public TCollection


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 and the
key comparison is done via the IsEqual() function.
Both key and value must inherit from TObject.

/* */


Function Members (Methods)

public:
TMap(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0)
virtual~TMap()
voidTObject::AbstractMethod(const char* method) const
virtual voidAdd(TObject* obj)
voidAdd(TObject* key, TObject* value)
virtual voidTCollection::AddAll(const TCollection* col)
voidTCollection::AddVector(TObject* obj1)
virtual voidTObject::AppendPad(Option_t* option = "")
Bool_tTCollection::AssertClass(TClass* cl) const
Float_tAverageCollisions() const
virtual voidTCollection::Browse(TBrowser* b)
Int_tCapacity() const
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidClear(Option_t* option = "")
virtual TObject*TObject::Clone(const char* newname = "") const
Int_tCollisions(const char* keyname) const
Int_tCollisions(TObject* key) const
virtual Int_tTCollection::Compare(const TObject* obj) const
Bool_tTCollection::Contains(const char* name) const
Bool_tTCollection::Contains(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
virtual voidDelete(Option_t* option = "")
voidDeleteAll()
Bool_tDeleteEntry(TObject* key)
voidDeleteKeys()
voidDeleteValues()
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTCollection::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTCollection::Dump() const
static voidTCollection::EmptyGarbageCollection()
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*FindObject(const char* keyname) const
virtual TObject*FindObject(const TObject* key) const
static voidTCollection::GarbageCollect(TObject* obj)
static TCollection*TCollection::GetCurrentCollection()
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual Int_tTCollection::GetEntries() const
virtual const char*TObject::GetIconName() const
virtual const char*TCollection::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
virtual TObject**GetObjectRef(const TObject* obj) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual Int_tTCollection::GetSize() const
const THashTable*GetTable() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
TObject*GetValue(const char* keyname) const
TObject*GetValue(const TObject* key) const
virtual Int_tTCollection::GrowBy(Int_t delta) const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTCollection::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
Bool_tTCollection::IsArgNull(const char* where, const TObject* obj) const
virtual Bool_tTCollection::IsEmpty() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTCollection::IsFolder() const
Bool_tTObject::IsOnHeap() const
Bool_tTCollection::IsOwner() const
Bool_tIsOwnerValue() const
virtual Bool_tTCollection::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTCollection::ls(Option_t* option = "") const
virtual TIterator*MakeIterator(Bool_t dir = kIterForward) const
virtual TIterator*TCollection::MakeReverseIterator() const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TObject*operator()(const char* keyname) const
TObject*operator()(const TObject* key) const
virtual voidTCollection::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTCollection::Print(Option_t* option = "") const
virtual voidTCollection::Print(Option_t* option, Int_t recurse) const
virtual voidTCollection::Print(Option_t* option, const char* wildcard, Int_t recurse = 1) const
virtual voidTCollection::Print(Option_t* option, TPRegexp& regexp, Int_t recurse = 1) const
virtual Int_tTObject::Read(const char* name)
virtual voidTCollection::RecursiveRemove(TObject* obj)
voidRehash(Int_t newCapacity, Bool_t checkObjValidity = kTRUE)
virtual TObject*Remove(TObject* key)
voidTCollection::RemoveAll()
virtual voidTCollection::RemoveAll(TCollection* col)
TPair*RemoveEntry(TObject* key)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidTCollection::SetCurrentCollection()
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidTCollection::SetName(const char* name)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTCollection::SetOwner(Bool_t enable = kTRUE)
virtual voidSetOwnerKeyValue(Bool_t ownkeys = kTRUE, Bool_t ownvals = kTRUE)
virtual voidSetOwnerValue(Bool_t enable = kTRUE)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
static voidTCollection::StartGarbageCollection()
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTCollection::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTCollection::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
virtual const char*TCollection::GetCollectionEntryName(TObject* entry) const
voidTObject::MakeZombie()
virtual voidPrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const
virtual voidTCollection::PrintCollectionHeader(Option_t* option) const
private:
TMap(const TMap& map)
TMap&operator=(const TMap& map)

Data Members

public:
enum { kIsOwnerValue
};
enum TCollection::[unnamed] { kIsOwner
kInitCapacity
kInitHashTableCapacity
};
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
protected:
TStringTCollection::fNamename of the collection
Int_tTCollection::fSizenumber of elements in collection
private:
THashTable*fTableHash table used to store TPair's

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TMap(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0)
 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* obj)
 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()
 Return the ratio of entries vs occupied slots.
Int_t Capacity()
 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. The keys/values are
 deleted depending on the state of key-ownership (SetOwner()) and
 value-ownership (SetOwnerValue()).

 To delete these objects regardless of the ownership state use:
  - Delete()       to delete only keys;
  - DeleteValues() to delete only values;
  - DeleteAll()    to delete both keys and values.
Int_t Collisions(const char *keyname)
 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)
 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.
Bool_t DeleteEntry(TObject* key)
 Remove (key,value) pair with key from the map. Returns true
 if the key was found and removed, false otherwise.
 The key and value objects are deleted if map is the owner
 of keys and values respectively.
TObject * FindObject(const char *keyname)
 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)
 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)
 Returns a pointer to the value associated with keyname as name of the key.
TObject * GetValue(const TObject *key)
 Returns a pointer to the value associated with key.
TIterator * MakeIterator(Bool_t dir = kIterForward) const
 Create an iterator for TMap.
void PrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const
 Print the collection entry.
void Rehash(Int_t newCapacity, Bool_t checkObjValidity = kTRUE)
 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. If map is the owner
 of values, the value is deleted.
TPair * RemoveEntry(TObject* key)
 Remove (key,value) pair with key from the map. Returns the
 pair object or 0 in case the key was not found.
 It is caller's responsibility to delete the pair and, eventually,
 the key and value objects.
void SetOwnerValue(Bool_t enable = kTRUE)
 Set whether this map is the owner (enable==true)
 of its values.  If it is the owner of its contents,
 these objects will be deleted whenever the collection itself
 is deleted. The objects might also be deleted or destructed when Clear
 is called (depending on the collection).
void SetOwnerKeyValue(Bool_t ownkeys = kTRUE, Bool_t ownvals = kTRUE)
 Set ownership for keys and values.
void Streamer(TBuffer& b)
 Stream all key/value pairs in the map to or from the I/O buffer.
TMap(const TMap& map)
TMap& operator=(const TMap& map)
void DeleteKeys()
{ Delete(); }
TObject ** GetObjectRef(const TObject* obj) const
{ return fTable->GetObjectRef(obj); }
const THashTable * GetTable()
{ return fTable; }
Bool_t IsOwnerValue()
{ return TestBit(kIsOwnerValue); }
TObject * operator()(const char *keyname)
{ return GetValue(keyname); }
TObject * operator()(const TObject *key)
{ return GetValue(key); }

Author: Fons Rademakers 12/11/95
Last change: root/cont:$Id: TMap.h 25128 2008-08-12 17:59:19Z pcanal $
Last generated: 2008-08-18 08:38
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *

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.