-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.h
More file actions
50 lines (39 loc) · 949 Bytes
/
Map.h
File metadata and controls
50 lines (39 loc) · 949 Bytes
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
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
// Interface to the Map ADT that maps strings to integers
// !!! DO NOT MODIFY THIS FILE !!!
#ifndef MAP_H
#define MAP_H
#include <stdbool.h>
typedef struct map *Map;
/**
* Creates a new map
* Time complexity: O(1)
*/
Map MapNew(void);
/**
* Frees all memory allocated to the given map
* Time complexity: O(n)
*/
void MapFree(Map m);
/**
* Adds a key-value pair to the map. If the key already exists in the
* map, its value is replaced with the given value. Makes a copy of the
* key.
* Time complexity: O(n)
*/
void MapSet(Map m, char *key, int value);
/**
* Checks if the map contains the given key
* Time complexity: O(log n)
*/
bool MapContains(Map m, char *key);
/**
* Gets the value associated with the given key. The key is assumed to
* exist.
* Time complexity: O(log n)
*/
int MapGet(Map m, char *key);
#endif