Package ints
Class IntIntMap
java.lang.Object
ints.IntIntMap
Class IntIntMap represents a map with integer keys and integer
 values.
 
Class IntIntMap is not thread-safe.
 
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Removes all keys from this map.booleancontains(int key) Returnstrueif the map contains the specified key, and returnsfalseotherwise.intget(int key, int sentinel) Returns the value for the specified key or the specified sentinel value if the specified key is not present in this map.intkey(int index) Returns the specified key.int[]keys()Returns an array containing the keys in this map.booleanput(int key, int value) Adds the specified key and value to this map.booleanremove(int key) Removes the specified key from this map.intsize()Returns the number of keys in this map.toString()Returnsjava.util.Arrays.toString(this.keys()).int[]values()Returns an array containing the values in this map.
- 
Constructor Details- 
IntIntMappublic IntIntMap(int capacity) Creates a newIntMapinstance.- Parameters:
- capacity- the initial capacity of this map
- Throws:
- IllegalArgumentException- if- capacity < 0 || (capacity > (1 << 30))
 
 
- 
- 
Method Details- 
clearpublic void clear()Removes all keys from this map.
- 
containspublic boolean contains(int key) Returnstrueif the map contains the specified key, and returnsfalseotherwise.- Parameters:
- key- a key
- Returns:
- trueif the map contains the specified key
 
- 
putpublic boolean put(int key, int value) Adds the specified key and value to this map. Returnstrueif this map was changed by the operation, and returnsfalseotherwise. The indexing of keys immediately before and after this method is invoked may differ if this map was changed by the operation.- Parameters:
- key- they key
- value- the value
- Returns:
- trueif this map was changed by the operation
 
- 
removepublic boolean remove(int key) Removes the specified key from this map. Returnstrueif this map was changed by the operation, and returnsfalseotherwise. The indexing of keys immediately before and after this method is invoked may differ if this map was changed by the operation.- Parameters:
- key- a key index
- Returns:
- trueif this map was changed by the operation
 
- 
keypublic int key(int index) Returns the specified key.- Parameters:
- index- an index of a key in this map
- Returns:
- the specified key
- Throws:
- IndexOutOfBoundsException- if- index < 0 || index >= this.size()
 
- 
getpublic int get(int key, int sentinel) Returns the value for the specified key or the specified sentinel value if the specified key is not present in this map.- Parameters:
- key- the key
- sentinel- the value to be returned if the specified key is not present in this map
- Returns:
- the specified value
 
- 
sizepublic int size()Returns the number of keys in this map.- Returns:
- the number of keys in this map
 
- 
keyspublic int[] keys()Returns an array containing the keys in this map. The returned array will satisfy:this.toArray()[j]==this.key(j)for eachjsatisfying(0 <= j && j < this.size()).- Returns:
- an array containing the keys in this map
 
- 
valuespublic int[] values()Returns an array containing the values in this map. The returned array will satisfy:this.toArray()[j]==this.value(this.key(j))for eachjsatisfying(0 <= j && j < this.size()).- Returns:
- an array containing the values in this map
 
- 
toStringReturnsjava.util.Arrays.toString(this.keys()).
 
-