-
Notifications
You must be signed in to change notification settings - Fork 0
/
array-dictionary.h
executable file
·44 lines (30 loc) · 992 Bytes
/
array-dictionary.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
#if !defined ARRAY_DICTIONARY_H
#define ARRAY_DICTIONARY_H
// Implementation of a dictionary using an array and sequential search
// The array will be dynamically resized if necessary
#include "dictionary.h"
struct ArrayDictionaryNode {
char * key;
void * data;
};
class ArrayDictionary : public Dictionary {
protected:
ArrayDictionaryNode *array;
int maxNumber;
int currentNumber;
public:
// Constructor
ArrayDictionary();
// Add a record to the dictionary. Returns false if key already exists
bool addRecord( KeyType key, DataType record);
// Find a key in the dictionary and return corresponding record or NULL
// Use sequential search
DataType findRecord( KeyType key);
// Removes one element from the table
bool removeElement(KeyType key);
// Returns all the elements in the table as an array of strings.
// *n is the size of the table and it is returned by reference
KeyType * keys(int * n);
// Add other methods you may need
};
#endif