forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashmap.d.ts
130 lines (112 loc) · 2.77 KB
/
hashmap.d.ts
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Type definitions for HashMap 2.0.3
// Project: https://github.com/flesler/hashmap
// Definitions by: Rafał Wrzeszcz <http://wrzasq.pl>, Vasya Aksyonov <https://github.com/outring>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare class HashMap<TKey, TValue> {
/**
* Creates an empty hashmap.
*/
constructor();
/**
* Creates a hashmap with the key-value pairs of map.
*
* @param map
*/
constructor(map:HashMap<TKey, TValue>);
/**
* Creates a hashmap with several key-value pairs.
*
* @param keysAndValues key1, value1, key2, value2...
*/
constructor(...keysAndValues:(TKey|TValue)[]);
/**
* Return value from hashmap.
*
* @param key Key.
* @return Value stored under given key.
*/
get(key:TKey):TValue;
/**
* Store value in hashmap.
*
* @param key Key.
* @param value Value.
* @return Self.
*/
set(key:TKey, value:TValue):HashMap<TKey, TValue>;
/**
* Store several key-value pairs.
*
* @param keysAndValues key1, value1, key2, value2...
* @return Self.
*/
multi(...keysAndValues:(TKey|TValue)[]):HashMap<TKey, TValue>;
/**
* Copy all key-value pairs from other to this instance.
*
* @param map Other map.
* @return Self.
*/
copy(map:HashMap<TKey, TValue>):HashMap<TKey, TValue>;
/**
* Checks if given key exists in hashmap.
*
* @param key Key.
* @return Whether given key exists in hashmap.
*/
has(key:TKey):boolean;
/**
* Returns key under which given value is stored.
*
* @param value Value.
* @return Key which is assigned to value stored.
*/
search(value:TValue):TKey;
/**
* Removes given key from hashmap.
*
* @param key Key.
* @return Self.
*/
remove(key:TKey):HashMap<TKey, TValue>;
/**
* Returns all contained keys.
*
* @return List of keys.
*/
keys():TKey[];
/**
* Returns all container values.
*
* @return List of values.
*/
values():TValue[];
/**
* Returns size of hashmap (number of entries).
*
* @return Number of entries in hashmap.
*/
count():number;
/**
* Clears hashmap.
*
* @return Self.
*/
clear():HashMap<TKey, TValue>;
/**
* Creates a new hashmap with all the key-value pairs of the original
*
* @return New hashmap.
*/
clone():HashMap<TKey, TValue>;
/**
* Iterates over hashmap.
*
* @param callback Function to be invoked for every hashmap entry.
* @return Self.
*/
forEach(callback:(value:TValue, key:TKey) => void):HashMap<TKey, TValue>;
}
declare module "hashmap" {
export = HashMap;
}