Package org.elasticsearch.common.collect
Class ImmutableOpenIntMap<VType>
- java.lang.Object
-
- org.elasticsearch.common.collect.ImmutableOpenIntMap<VType>
-
- All Implemented Interfaces:
java.lang.Iterable<com.carrotsearch.hppc.cursors.IntObjectCursor<VType>>
public final class ImmutableOpenIntMap<VType> extends java.lang.Object implements java.lang.Iterable<com.carrotsearch.hppc.cursors.IntObjectCursor<VType>>
An immutable map implementation based on open hash map.Can be constructed using a
builder()
, or usingbuilder(org.elasticsearch.common.collect.ImmutableOpenIntMap)
(which is an optimized option to copy over existing content and modify it).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImmutableOpenIntMap.Builder<VType>
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <VType> ImmutableOpenIntMap.Builder<VType>
builder()
static <VType> ImmutableOpenIntMap.Builder<VType>
builder(int size)
static <VType> ImmutableOpenIntMap.Builder<VType>
builder(ImmutableOpenIntMap<VType> map)
boolean
containsKey(int key)
Returnstrue
if this container has an association to a value for the given key.boolean
equals(java.lang.Object o)
VType
get(int key)
int
hashCode()
boolean
isEmpty()
java.util.Iterator<com.carrotsearch.hppc.cursors.IntObjectCursor<VType>>
iterator()
Returns a cursor over the entries (key-value pairs) in this map.com.carrotsearch.hppc.IntLookupContainer
keys()
Returns a specialized view of the keys of this associated container.java.util.Iterator<java.lang.Integer>
keysIt()
Returns a direct iterator over the keys.static <VType> ImmutableOpenIntMap<VType>
of()
int
size()
java.lang.String
toString()
com.carrotsearch.hppc.ObjectContainer<VType>
values()
java.util.Iterator<VType>
valuesIt()
Returns a direct iterator over the keys.
-
-
-
Method Detail
-
get
public VType get(int key)
- Returns:
- Returns the value associated with the given key or the default value
for the key type, if the key is not associated with any value.
Important note: For primitive type values, the value returned for a non-existing key may not be the default value of the primitive type (it may be any value previously assigned to that slot).
-
containsKey
public boolean containsKey(int key)
Returnstrue
if this container has an association to a value for the given key.
-
size
public int size()
- Returns:
- Returns the current size (number of assigned keys) in the container.
-
isEmpty
public boolean isEmpty()
- Returns:
- Return
true
if this hash map contains no assigned keys.
-
iterator
public java.util.Iterator<com.carrotsearch.hppc.cursors.IntObjectCursor<VType>> iterator()
Returns a cursor over the entries (key-value pairs) in this map. The iterator is implemented as a cursor and it returns the same cursor instance on every call toIterator.next()
. To read the current key and value use the cursor's public fields. An example is shown below.for (IntShortCursor c : intShortMap) { System.out.println("index=" + c.index + " key=" + c.key + " value=" + c.value); }
The
index
field inside the cursor gives the internal index inside the container's implementation. The interpretation of this index depends on to the container.- Specified by:
iterator
in interfacejava.lang.Iterable<VType>
-
keys
public com.carrotsearch.hppc.IntLookupContainer keys()
Returns a specialized view of the keys of this associated container. The view additionally implementsObjectLookupContainer
.
-
keysIt
public java.util.Iterator<java.lang.Integer> keysIt()
Returns a direct iterator over the keys.
-
values
public com.carrotsearch.hppc.ObjectContainer<VType> values()
- Returns:
- Returns a container with all values stored in this map.
-
valuesIt
public java.util.Iterator<VType> valuesIt()
Returns a direct iterator over the keys.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
of
public static <VType> ImmutableOpenIntMap<VType> of()
-
builder
public static <VType> ImmutableOpenIntMap.Builder<VType> builder()
-
builder
public static <VType> ImmutableOpenIntMap.Builder<VType> builder(int size)
-
builder
public static <VType> ImmutableOpenIntMap.Builder<VType> builder(ImmutableOpenIntMap<VType> map)
-
-