summaryrefslogtreecommitdiffstats
path: root/kmail/tdemdict.h
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:50 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:50 -0600
commitb363d2579af0a11b77e698aed2e1021c2233b644 (patch)
treef4a47b87354b7a6a3b266c8121bd8ddaeb7accaa /kmail/tdemdict.h
parent61bddfe3a7226b18c68a76124b727c736f431688 (diff)
downloadtdepim-b363d2579af0a11b77e698aed2e1021c2233b644.tar.gz
tdepim-b363d2579af0a11b77e698aed2e1021c2233b644.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'kmail/tdemdict.h')
-rw-r--r--kmail/tdemdict.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/kmail/tdemdict.h b/kmail/tdemdict.h
new file mode 100644
index 000000000..6cbbefd5a
--- /dev/null
+++ b/kmail/tdemdict.h
@@ -0,0 +1,68 @@
+/*
+ * simple hash table for kmail. inspired by TQDict
+ */
+
+#ifndef __KMDICT
+#define __KMDICT
+
+/**
+ * @short Class representing items in a KMDict
+ */
+class KMDictItem
+{
+public:
+ long key;
+ KMDictItem *next;
+};
+
+/**
+ * @short KMDict implements a lightweight dictionary with serial numbers as keys.
+ *
+ * KMDict is a leightweight dictionary used exclusively by KMMsgDict. It uses
+ * serial numbers as keys.
+ *
+ * @author Ronen Tzur <rtzur@shani.net>
+ */
+class KMDict
+{
+ friend class MessageDictTester;
+public:
+ /** Creates a hash table with @p size columns. */
+ KMDict(int size = 17);
+
+ /** Destroys the hash table object. */
+ ~KMDict();
+
+ /** Clears the hash table, removing all items. */
+ void clear();
+
+ /** Returns the size of the hash table. */
+ int size() { return mSize; }
+
+ /** Inserts an item, replacing old ones with the same key. */
+ void replace(long key, KMDictItem *item);
+
+ /** Inserts an item without replacing ones with the same key. */
+ void insert(long key, KMDictItem *item);
+
+ /** Removes an item. */
+ void remove(long key);
+
+ /** Find an item by key. Returns pointer to it, or 0 if not found. */
+ KMDictItem *find(long key);
+
+private:
+ /** Removes all items _following_ @p item with key @p key. */
+ void removeFollowing(KMDictItem *item, long key);
+
+ /** Initializes the hash table to @p size colums. */
+ void init(int size);
+
+ /** The size of the hash. */
+ int mSize;
+
+ /** The buckets. */
+ KMDictItem **mVecs;
+};
+
+#endif /* __KMDICT */