summaryrefslogtreecommitdiffstats
path: root/kmail/kmdict.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kmail/kmdict.h
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail/kmdict.h')
-rw-r--r--kmail/kmdict.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/kmail/kmdict.h b/kmail/kmdict.h
new file mode 100644
index 000000000..520315ad2
--- /dev/null
+++ b/kmail/kmdict.h
@@ -0,0 +1,68 @@
+/*
+ * simple hash table for kmail. inspired by QDict
+ */
+
+#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 */