10 #define FixedSizeSet_h
18 template <
typename T,
class Hash = std::hash<T>>
39 size_t hash =
h(item);
42 if (f->item == item && f->valid)
48 void insert(
const T &item);
60 template <
typename T,
class Hash>
67 c = currentMemoryEntry;
81 template <
typename T,
class Hash>
84 hashTableSize = (2*capacity)|1;
85 hashTable =
new field*[hashTableSize];
86 memory =
new field[capacity];
87 memset(memory, 0x0, capacity*
sizeof(
field));
88 memset(hashTable, 0x0, hashTableSize*
sizeof(
field*));
89 currentMemoryEntry = 0;
90 this->capacity = capacity;
94 template <
typename T,
class Hash>
101 currentMemoryEntry = 0;
106 template <
typename T,
class Hash>
117 this->capacity = capacity;
120 hashTableSize = (2*capacity)|1;
121 hashTable =
new field*[hashTableSize];
122 memory =
new field[capacity];
123 memset(memory, 0x0, capacity*
sizeof(
field));
124 memset(hashTable, 0x0, hashTableSize*
sizeof(
field*));
125 currentMemoryEntry = 0;
130 template <
typename T,
class Hash>
133 currentMemoryEntry = 0;
135 memset(hashTable, 0x0, capacity*
sizeof(
field*));
136 memset(memory, 0x0, capacity*
sizeof(
field));
139 template <
typename T,
class Hash>
142 std::vector<int> dist;
143 for (
int x = 0; x < hashTableSize; x++)
146 for (
field* f = hashTable[x]; f; f = f->
next)
150 if (len >= dist.size())
154 for (
int x = 0; x < dist.size(); x++)
155 printf(
"%d : %d\n", x, dist[x]);
158 template <
typename T,
class Hash>
168 template <
typename T,
class Hash>
171 size_t hash = h(item);
172 if (hashTable[hash%hashTableSize] == 0)
174 field *f = &memory[currentMemoryEntry];
175 currentMemoryEntry++;
179 hashTable[hash%hashTableSize] = f;
182 for (
field* t = hashTable[hash%hashTableSize]; t; t = t->
next)
188 field *f = &memory[currentMemoryEntry];
189 currentMemoryEntry++;
201 class fssIterator :
public std::iterator<std::random_access_iterator_tag, T, ptrdiff_t, T*, T&>