SASC-NG
DVBSoftCAM

cHashBase Class Reference

#include <tools.h>

Inheritance diagram for cHashBase:

List of all members.

Public Member Functions

virtual ~cHashBase ()
void Add (cListObject *Object, unsigned int Id)
void Del (cListObject *Object, unsigned int Id)
void Clear (void)
cListObject * Get (unsigned int Id) const
cList< cHashObject > * GetList (unsigned int Id) const

Protected Member Functions

 cHashBase (int Size)

Detailed Description

Definition at line 497 of file tools.h.


Constructor & Destructor Documentation

cHashBase::cHashBase ( int  Size) [protected]

Definition at line 1088 of file tools.cpp.

{
  size = Size;
  hashTable = (cList<cHashObject>**)calloc(size, sizeof(cList<cHashObject>*));
}
cHashBase::~cHashBase ( void  ) [virtual]

Definition at line 1094 of file tools.cpp.

References free, and i.

{
  for (int i = 0; i < size; i++)
      delete hashTable[i];
  free(hashTable);
}

Member Function Documentation

void cHashBase::Add ( cListObject *  Object,
unsigned int  Id 
)

Definition at line 1101 of file tools.cpp.

References cListBase::Add(), and hash.

{
  unsigned int hash = hashfn(Id);
  if (!hashTable[hash])
     hashTable[hash] = new cList<cHashObject>;
  hashTable[hash]->Add(new cHashObject(Object, Id));
}
void cHashBase::Clear ( void  )
void cHashBase::Del ( cListObject *  Object,
unsigned int  Id 
)

Definition at line 1109 of file tools.cpp.

References cListBase::Del(), cList< T >::First(), and cList< T >::Next().

{
  cList<cHashObject> *list = hashTable[hashfn(Id)];
  if (list) {
     for (cHashObject *hob = list->First(); hob; hob = list->Next(hob)) {
         if (hob->object == Object) {
            list->Del(hob);
            break;
            }
         }
     }
}
cListObject * cHashBase::Get ( unsigned int  Id) const

Reimplemented in cHash< T >, cHash< cEvent >, and cHash< cChannel >.

Definition at line 1122 of file tools.cpp.

References cList< T >::First(), cList< T >::Next(), and NULL.

Referenced by cHash< cChannel >::Get().

{
  cList<cHashObject> *list = hashTable[hashfn(Id)];
  if (list) {
     for (cHashObject *hob = list->First(); hob; hob = list->Next(hob)) {
         if (hob->id == Id)
            return hob->object;
         }
     }
  return NULL;
}
cList< cHashObject > * cHashBase::GetList ( unsigned int  Id) const

Definition at line 1134 of file tools.cpp.

{
  return hashTable[hashfn(Id)];
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines