it.unimi.dsi.fastutil.objects
Class ObjectLists

java.lang.Object
  extended by it.unimi.dsi.fastutil.objects.ObjectLists

public class ObjectLists
extends Object

A class providing static methods and objects that do useful things with type-specific lists.

See Also:
Collections

Nested Class Summary
static class ObjectLists.EmptyList<K>
          An immutable class representing an empty type-specific list.
static class ObjectLists.Singleton<K>
          An immutable class representing a type-specific singleton list.
static class ObjectLists.SynchronizedList<K>
          A synchronized wrapper class for lists.
static class ObjectLists.UnmodifiableList<K>
          An unmodifiable wrapper class for lists.
 
Field Summary
static ObjectLists.EmptyList EMPTY_LIST
          An empty list (immutable).
 
Method Summary
static
<K> ObjectList<K>
shuffle(ObjectList<K> l, Random random)
          Shuffles the specified list using the specified pseudorandom number generator.
static
<K> ObjectList<K>
singleton(K element)
          Returns a type-specific immutable list containing only the specified element.
static
<K> ObjectList<K>
synchronize(ObjectList<K> l)
          Returns a synchronized type-specific list backed by the given type-specific list.
static
<K> ObjectList<K>
synchronize(ObjectList<K> l, Object sync)
          Returns a synchronized type-specific list backed by the given type-specific list, using an assigned object to synchronize.
static
<K> ObjectList<K>
unmodifiable(ObjectList<K> l)
          Returns an unmodifiable type-specific list backed by the given type-specific list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_LIST

public static final ObjectLists.EmptyList EMPTY_LIST
An empty list (immutable). It is serializable and cloneable.

The class of this objects represent an abstract empty list that is a sublist of any type of list. Thus, EMPTY_LIST may be assigned to a variable of any (sorted) type-specific list.

Method Detail

shuffle

public static <K> ObjectList<K> shuffle(ObjectList<K> l,
                                        Random random)
Shuffles the specified list using the specified pseudorandom number generator.

Parameters:
l - the list to be shuffled.
random - a pseudorandom number generator (please use a XorShift* generator).
Returns:
l.

singleton

public static <K> ObjectList<K> singleton(K element)
Returns a type-specific immutable list containing only the specified element. The returned list is serializable and cloneable.

Parameters:
element - the only element of the returned list.
Returns:
a type-specific immutable list containing just element.

synchronize

public static <K> ObjectList<K> synchronize(ObjectList<K> l)
Returns a synchronized type-specific list backed by the given type-specific list.

Parameters:
l - the list to be wrapped in a synchronized list.
Returns:
a synchronized view of the specified list.
See Also:
Collections.synchronizedList(List)

synchronize

public static <K> ObjectList<K> synchronize(ObjectList<K> l,
                                            Object sync)
Returns a synchronized type-specific list backed by the given type-specific list, using an assigned object to synchronize.

Parameters:
l - the list to be wrapped in a synchronized list.
sync - an object that will be used to synchronize the access to the list.
Returns:
a synchronized view of the specified list.
See Also:
Collections.synchronizedList(List)

unmodifiable

public static <K> ObjectList<K> unmodifiable(ObjectList<K> l)
Returns an unmodifiable type-specific list backed by the given type-specific list.

Parameters:
l - the list to be wrapped in an unmodifiable list.
Returns:
an unmodifiable view of the specified list.
See Also:
Collections.unmodifiableList(List)