-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionary.h
More file actions
58 lines (45 loc) · 1.36 KB
/
Dictionary.h
File metadata and controls
58 lines (45 loc) · 1.36 KB
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
//-----------------------------------------------------------------------------
// Dictionary.h
// Header file for the Dictionary ADT
//-----------------------------------------------------------------------------
#ifndef _DICTIONARY_H_INCLUDE_
#define _DICTIONARY_H_INCLUDE_
// Dictionary
// Exported reference type
typedef struct DictionaryObj* Dictionary;
// newDictionary()
// constructor for the Dictionary type
Dictionary newDictionary(void);
// freeDictionary()
// destructor for the Dictionary type
void freeDictionary(Dictionary* pD);
// isEmpty()
// returns 1 (true) if S is empty, 0 (false) otherwise
// pre: none
int isEmpty(Dictionary D);
// size()
// returns the number of (key, value) pairs in D
// pre: none
int size(Dictionary D);
// lookup()
// returns the value v such that (k, v) is in D, or returns NULL if no
// such value v exists.
// pre: none
char* lookup(Dictionary D, char* k);
// insert()
// inserts new (key,value) pair into D
// pre: lookup(D, k)==NULL
void insert(Dictionary D, char* k, char* v);
// delete()
// deletes pair with the key k
// pre: lookup(D, k)!=NULL
void delete(Dictionary D, char* k);
// makeEmpty()
// re-sets D to the empty state.
// pre: none
void makeEmpty(Dictionary D);
// printDictionary()
// pre: none
// prints a text representation of D to the file pointed to by out
void printDictionary(FILE* out, Dictionary D);
#endif