ch.bind.philib.util
Class StaticIntMap<T>

java.lang.Object
  extended by ch.bind.philib.util.StaticIntMap<T>

public final class StaticIntMap<T>
extends Object

A statically initialized and immutable map of int -> T.

Author:
Philipp Meinen

Method Summary
 boolean containsKey(int key)
           
static
<T> StaticIntMap<T>
create(Collection<? extends IntPair<T>> elements)
           
static
<T> StaticIntMap<T>
create(IntPair<T>[] elements)
           
 T get(int key)
           
 T getOrElse(int key, T defaultVal)
           
 T getOrThrow(int key)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static <T> StaticIntMap<T> create(Collection<? extends IntPair<T>> elements)
Parameters:
elements -
Returns:
A fully initialized StaticIntMap.
Throws:
IllegalArgumentException - If the elements parameter is null, empty or contains duplicate keys.
NullPointerException - If any value in elements is a null-value.

create

public static <T> StaticIntMap<T> create(IntPair<T>[] elements)
Parameters:
elements -
Returns:
A fully initialized StaticIntMap.
Throws:
IllegalArgumentException - If the elements parameter is null, empty or contains duplicate keys.
NullPointerException - If any value in elements is a null-value.

get

public T get(int key)
Parameters:
key -
Returns:
The value associated with key, which may be null.

getOrElse

public T getOrElse(int key,
                   T defaultVal)
Parameters:
key -
Returns:
The value associated with key, defaultVal otherwise.

getOrThrow

public T getOrThrow(int key)
             throws NoSuchElementException
Parameters:
key -
Returns:
The value associated with key, which may be null.
Throws:
NoSuchElementException - If no value is associated with key.

containsKey

public boolean containsKey(int key)

size

public int size()


Copyright © 2013. All Rights Reserved.