-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMutableMap.kt
More file actions
59 lines (51 loc) · 1.29 KB
/
MutableMap.kt
File metadata and controls
59 lines (51 loc) · 1.29 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
59
package dataStructures.hashMap
/**
* Interface that represents a MutableMap
*/
interface MutableMap<K, V> {
/**
* Interface that represents a MutableEntry
*/
interface MutableEntry<K, V> {
val key: K
val value: V
/**
* Sets a value to the [MutableEntry]
*
* @param newValue value to override
* @return the [newValue] set
*/
fun setValue(newValue: V): V
}
val size: Int
/**
* Adds an Entry to the Hashmap ([key] and [value])
* associated with the given [key]
*
* @param key Key to serve as an address
* @param value Value to put in the address of [key]
* @return the value or null if
*/
fun put(key: K, value: V): V?
/**
* Removes an Entry of the Hashmap given by a [key]
*
* @param key to search in the Hashmap to remove an entry
* @return Returns the value associated with [key] or null
* if [key] is not present in [HashMap]
*/
fun remove(key: K): V?
/**
* Function that returns the value of a given
* [key] or null if it doesn't exist in the [HashMap]
*
* @param key Key to find in the Hashmap
* @return Returns the first value associated with that
* given [key] or null if it isn't present in the Hashmap
*/
operator fun get(key: K): V?
/**
* Iterator of the [HashMap]
*/
operator fun iterator(): Iterator<MutableEntry<K, V>>
}