libUTL++
THashtable.h
1 #pragma once
2 
4 
5 #include <libutl/THashtableIt.h>
6 
8 
9 UTL_NS_BEGIN;
10 
12 
22 
24 template <class T>
25 class THashtable : public Hashtable
26 {
29 
30 public:
38  THashtable(size_t size, size_t maxPct = 90, bool owner = true, bool multiSet = true);
39 
45  THashtable(bool owner, bool multiSet = true);
46 
47  bool
48  add(const T& object)
49  {
50  return super::add(object);
51  }
52 
53  bool
54  add(const T* object)
55  {
56  return super::add(object);
57  }
58 
59  void
60  add(const Collection& collection)
61  {
62  super::add(collection);
63  }
64 
66  begin() const
67  {
68  THashtableIt<T> res;
69  res.copy(Hashtable::begin());
70  return res;
71  }
72 
74  begin()
75  {
76  THashtableIt<T> res;
77  res.copy(Hashtable::begin());
78  return res;
79  }
80 
82  end() const
83  {
84  THashtableIt<T> res;
85  res.copy(Hashtable::end());
86  return res;
87  }
88 
90  end()
91  {
92  THashtableIt<T> res;
93  res.copy(Hashtable::end());
94  return res;
95  }
96 
98  T*
99  findT(const Object& key) const
100  {
101  return utl::cast<T>(Hashtable::find(key));
102  }
103 
104 public:
105  typedef T type;
106  typedef THashtableIt<T> iterator;
107  typedef T* value_type; // for STL
108 };
109 
111 
112 template <class T>
113 THashtable<T>::THashtable(size_t size, size_t maxPct, bool owner, bool multiSet)
114  : Hashtable(size, maxPct, owner, multiSet)
115 {
116 }
117 
119 
120 template <class T>
121 THashtable<T>::THashtable(bool owner, bool multiSet)
122  : Hashtable(owner, multiSet)
123 {
124 }
125 
127 
128 UTL_NS_END;
129 
131 
#define UTL_CLASS_IMPL_TPL(className, T)
Implementation of standard UTL++ functionality for a template class.
Definition: macros.h:906
#define UTL_CLASS_DEFID
Default init() and deInit() (which are merely place-holders).
Definition: macros.h:532
T * findT(const Object &key) const
See find().
Definition: THashtable.h:99
Templated proxy for BidIt.
Definition: TBidIt.h:19
THashtable(size_t size, size_t maxPct=90, bool owner=true, bool multiSet=true)
Constructor.
Definition: THashtable.h:113
Template version of HashtableIt.
Definition: THashtableIt.h:23
Template version of Hashtable.
Definition: THashtable.h:25
virtual void copy(const Object &rhs)
Copy another HashtableIt.
#define UTL_CLASS_DECL_TPL(DC, T, BC)
Declaration of standard UTL++ functionality for a template class with one parameter.
Definition: macros.h:713
Chained hashing collection.
Definition: Hashtable.h:92
Root of UTL++ class hierarchy.
Definition: Object.h:52
A collection of objects.
Definition: Collection.h:62