TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kmdict.h 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * simple hash table for kmail. inspired by TQDict
  3. */
  4. #ifndef __KMDICT
  5. #define __KMDICT
  6. /**
  7. * @short Class representing items in a KMDict
  8. */
  9. class KMDictItem
  10. {
  11. public:
  12. long key;
  13. KMDictItem *next;
  14. };
  15. /**
  16. * @short KMDict implements a lightweight dictionary with serial numbers as keys.
  17. *
  18. * KMDict is a leightweight dictionary used exclusively by KMMsgDict. It uses
  19. * serial numbers as keys.
  20. *
  21. * @author Ronen Tzur <rtzur@shani.net>
  22. */
  23. class KMDict
  24. {
  25. friend class MessageDictTester;
  26. public:
  27. /** Creates a hash table with @p size columns. */
  28. KMDict(int size = 17);
  29. /** Destroys the hash table object. */
  30. ~KMDict();
  31. /** Clears the hash table, removing all items. */
  32. void clear();
  33. /** Returns the size of the hash table. */
  34. int size() { return mSize; }
  35. /** Inserts an item, replacing old ones with the same key. */
  36. void replace(long key, KMDictItem *item);
  37. /** Inserts an item without replacing ones with the same key. */
  38. void insert(long key, KMDictItem *item);
  39. /** Removes an item. */
  40. void remove(long key);
  41. /** Find an item by key. Returns pointer to it, or 0 if not found. */
  42. KMDictItem *find(long key);
  43. private:
  44. /** Removes all items _following_ @p item with key @p key. */
  45. void removeFollowing(KMDictItem *item, long key);
  46. /** Initializes the hash table to @p size colums. */
  47. void init(int size);
  48. /** The size of the hash. */
  49. int mSize;
  50. /** The buckets. */
  51. KMDictItem **mVecs;
  52. };
  53. #endif /* __KMDICT */