1 /**
2 * Copyright (C) ARM Limited 2010-2011. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
10 #ifndef __HASH_MAP_H__
11 #define __HASH_MAP_H__
13 /**********************************
14 This class is a limited and lossy hash map, where each hash table bucket will contain at most MAX_COLLISIONS entries
15 If the limit is exceeded, one of the old entries is dropped from the table
16 This limit eliminates the need for dynamic memory allocation
17 It is efficient with a data set containing a lot of use-only-once data
18 Zero is used as an invalid (unused) hash entry value
19 **********************************/
21 #define HASHMAP_ENTRIES 1024 /* must be power of 2 */
22 #define MAX_COLLISIONS 2
24 class HashMap {
25 public:
26 HashMap();
27 ~HashMap();
28 bool existsAdd(int value);
29 private:
30 int *hashEntries(int key);
31 int *history;
32 };
34 #endif //__HASH_MAP_H__