Package com.csse3200.game.utils
Class SortedIntMap<V>
java.lang.Object
com.csse3200.game.utils.SortedIntMap<V>
- Type Parameters:
V
- Class type to map
- All Implemented Interfaces:
Iterable<V>
A map sorted by the value of key with O(1) iteration. put/get/contains are O(n). useful when we
don't modify values often, but want to iterate quickly.
-
Constructor Summary
ConstructorDescriptionSortedIntMap
(int capacity) Create a sorted intmap with the specified capacity -
Method Summary
-
Constructor Details
-
SortedIntMap
public SortedIntMap(int capacity) Create a sorted intmap with the specified capacity- Parameters:
capacity
- initial capacity
-
-
Method Details
-
containsKey
public boolean containsKey(int key) - Parameters:
key
- map key- Returns:
- true if map contains key
-
contains
- Parameters:
value
- value in map- Returns:
- true if map contains value
-
put
Put key, value pair in map- Parameters:
key
- keyvalue
- value
-
get
Get value from map- Parameters:
key
- map key- Returns:
- map value or null if not found
-
clear
public void clear()Clear the map -
iterator
-
forEach
-
spliterator
- Specified by:
spliterator
in interfaceIterable<V>
-