-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathHashMap.h
59 lines (51 loc) · 1.55 KB
/
HashMap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* $Id: HashMap.h,v 1.29 2002-04-19 07:53:54 pgr Exp $ */
#ifndef COM_JAXO_YAXX_HASHMAP_H_INCLUDED
#define COM_JAXO_YAXX_HASHMAP_H_INCLUDED
/*---------+
| Includes |
+---------*/
#include "RexxString.h"
#ifdef YAXX_NAMESPACE
namespace YAXX_NAMESPACE {
#endif
/*------------------------------------------------------------ class MapItem -+
| |
+----------------------------------------------------------------------------*/
class MapItem {
friend class HashMap;
public:
MapItem(RexxString const & key) : m_key(key) {}
RexxString & key() { return m_key; }
protected:
RexxString m_key;
virtual ~MapItem() {}
private:
MapItem * m_next;
};
/*------------------------------------------------------------ class HashMap -+
| |
+----------------------------------------------------------------------------*/
class REXX_API HashMap {
public:
HashMap(int capacity = 11);
~HashMap();
MapItem * put(MapItem * pItm);
MapItem * get(RexxString const & key);
void clear();
void remove(RexxString const & key);
void iterate(
void (forEachEntry)(MapItem * itm, void * arg),
void * arg
);
void print();
private:
HashMap(HashMap const &); // undefined
HashMap & operator=(HashMap const &); // undefined
int m_capacity;
MapItem ** m_table;
};
#ifdef YAXX_NAMESPACE
}
#endif
#endif
/*===========================================================================*/