- java.lang.Object
-
- ch.bind.philib.util.StaticLongMap<T>
-
public final class StaticLongMap<T> extends Object
A statically initialized and immutable map oflong -> T.- Author:
- Philipp Meinen
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(long key)static <T> StaticLongMap<T>create(LongPair<T>[] elements)static <T> StaticLongMap<T>create(Collection<? extends LongPair<T>> elements)Tget(long key)TgetOrElse(long key, T defaultVal)TgetOrThrow(long key)intsize()
-
-
-
Method Detail
-
create
public static <T> StaticLongMap<T> create(Collection<? extends LongPair<T>> elements)
- Parameters:
elements-- Returns:
- A fully initialized
StaticLongMap. - Throws:
IllegalArgumentException- If theelementsparameter isnull, empty or contains duplicate keys.NullPointerException- If any value inelementsis anull-value.
-
create
public static <T> StaticLongMap<T> create(LongPair<T>[] elements)
- Parameters:
elements-- Returns:
- A fully initialized
StaticLongMap. - Throws:
IllegalArgumentException- If theelementsparameter isnull, empty or contains duplicate keys.NullPointerException- If any value inelementsis anull-value.
-
get
public T get(long key)
- Parameters:
key-- Returns:
- The value associated with
key, which may benull.
-
getOrElse
public T getOrElse(long key, T defaultVal)
- Parameters:
key-- Returns:
- The value associated with
key,defaultValotherwise.
-
getOrThrow
public T getOrThrow(long key) throws NoSuchElementException
- Parameters:
key-- Returns:
- The value associated with
key, which may benull. - Throws:
NoSuchElementException- If no value is associated withkey.
-
containsKey
public boolean containsKey(long key)
-
size
public int size()
-
-