ROOT » CORE » CONT » TMap

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:
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
TIterTCollection::begin() 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*TCollection::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()
TIterTCollection::end() const
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()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
voidTObject::operator delete(void* ptr)
voidTObject::operator delete(void* ptr, void* vp)
voidTObject::operator delete[](void* ptr)
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(ostream& 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) const
static voidTCollection::StartGarbageCollection()
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_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
TMap(Int_t capacity = TCollection::kInitHashTableCapacity, Int_t rehash = 0)
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tWrite(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tWrite(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&operator=(const TMap& map)
TMap(const TMap& map)

Data Members

public:
static TObject::<anonymous>TObject::kBitMask
static TObject::EStatusBitsTObject::kCanDelete
static TObject::EStatusBitsTObject::kCannotPick
static TObject::EStatusBitsTObject::kHasUUID
static TCollection::<anonymous>TCollection::kInitCapacity
static TCollection::<anonymous>TCollection::kInitHashTableCapacity
static TObject::EStatusBitsTObject::kInvalidObject
static TObject::<anonymous>TObject::kIsOnHeap
static TObject::EStatusBitsTObject::kIsReferenced
static TObject::EStatusBitsTObject::kMustCleanup
static TObject::EStatusBitsTObject::kNoContextMenu
static TObject::<anonymous>TObject::kNotDeleted
static TObject::EStatusBitsTObject::kObjInCanvas
static TObject::<anonymous>TObject::kOverwrite
static TObject::<anonymous>TObject::kSingleKey
static TObject::<anonymous>TObject::kWriteDelete
static TObject::<anonymous>TObject::kZombie
protected:
TStringTCollection::fNamename of the collection
Int_tTCollection::fSizenumber of elements in collection
static TCollection::<anonymous>TCollection::kIsOwner
static TMap::<anonymous>kIsOwnerValue
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() 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. 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) 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.
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) 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 = 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& )
 Stream all key/value pairs in the map to or from the I/O buffer.
Int_t Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
 Write all objects in this map. By default all objects in
 the collection are written individually (each object gets its
 own key). Note, this is recursive, i.e. objects in collections
 in the collection are also written individually. To write all
 objects using a single key specify a name and set option to
 TObject::kSingleKey (i.e. 1).
Int_t Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
 Write all objects in this map. By default all objects in
 the collection are written individually (each object gets its
 own key). Note, this is recursive, i.e. objects in collections
 in the collection are also written individually. To write all
 objects using a single key specify a name and set option to
 TObject::kSingleKey (i.e. 1).
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() const
{ return fTable; }
Bool_t IsOwnerValue() const
{ return TestBit(kIsOwnerValue); }
TObject * operator()(const char* keyname) const
{ return GetValue(keyname); }
TObject * operator()(const TObject* key) const
{ return GetValue(key); }