summaryrefslogtreecommitdiff
path: root/tools.h
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-05-28 13:17:20 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2005-05-28 13:17:20 +0200
commit7701acd968c91de94c1d0ae184a0f746c4ae5844 (patch)
treec66f7457c6dfd66eca823855a2f560d053d6d827 /tools.h
parentb4cbb84489020d0fa3e45fbff60cf1ce43ea6a1b (diff)
downloadvdr-7701acd968c91de94c1d0ae184a0f746c4ae5844.tar.gz
vdr-7701acd968c91de94c1d0ae184a0f746c4ae5844.tar.bz2
Now using hash tables to speed up cSchedule::GetEvent()
Diffstat (limited to 'tools.h')
-rw-r--r--tools.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/tools.h b/tools.h
index a45facbf..2c1f2a13 100644
--- a/tools.h
+++ b/tools.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.h 1.70 2005/05/26 11:34:01 kls Exp $
+ * $Id: tools.h 1.71 2005/05/28 11:24:49 kls Exp $
*/
#ifndef __TOOLS_H
@@ -236,4 +236,36 @@ public:
T *Next(const T *object) const { return (T *)object->cListObject::Next(); } // avoid ambiguities in case of a "list of lists"
};
+class cHashObject : public cListObject {
+ friend class cHashBase;
+private:
+ int id;
+ cListObject *object;
+public:
+ cHashObject(cListObject *Object, int Id) { object = Object; id = Id; }
+ };
+
+class cHashBase {
+private:
+ cList<cHashObject> **hashTable;
+ int size;
+ int hashfn(int Id) const { return Id % size; }
+protected:
+ cHashBase(int Size);
+public:
+ virtual ~cHashBase();
+ void Add(cListObject *Object, int Id);
+ void Del(cListObject *Object, int Id);
+ cListObject *Get(int Id) const;
+ cList<cHashObject> *GetList(int Id) const;
+ };
+
+#define HASHSIZE 512
+
+template<class T> class cHash : public cHashBase {
+public:
+ cHash(int Size = HASHSIZE) : cHashBase(Size) {}
+ T *Get(int Id) const { return (T *)cHashBase::Get(Id); }
+};
+
#endif //__TOOLS_H