edu.mit.csail.sdg.alloy4
Class ConstList<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<T>
          extended by edu.mit.csail.sdg.alloy4.ConstList<T>
Type Parameters:
T - - the type of element
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>, java.util.RandomAccess

public final class ConstList<T>
extends java.util.AbstractList<T>
implements java.io.Serializable, java.util.RandomAccess

Immutable; implements a list based on equals(); null values are allowed.

See Also:
Serialized Form

Nested Class Summary
static class ConstList.TempList<T>
          Mutable; this implements a modifiable list that can be used to construct a ConstList; null values are allowed.
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Method Summary
 T get(int index)
          Returns the i-th element
static
<T> ConstList<T>
make()
          Return an unmodifiable empty list.
static
<T> ConstList<T>
make(int n, T elem)
          Return an unmodifiable list consisting of "n" references to "elem".
static
<T> ConstList<T>
make(java.lang.Iterable<T> collection)
          Return an unmodifiable list with the same elements as the given collection.
 int size()
          Returns the number of elements in this list.
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Method Detail

make

public static <T> ConstList<T> make()
Return an unmodifiable empty list.


make

public static <T> ConstList<T> make(int n,
                                    T elem)
Return an unmodifiable list consisting of "n" references to "elem". (If n<=0, we'll return an unmodifiable empty list)


make

public static <T> ConstList<T> make(java.lang.Iterable<T> collection)
Return an unmodifiable list with the same elements as the given collection. (If collection==null, we'll return an unmodifiable empty list)


get

public T get(int index)
Returns the i-th element

Specified by:
get in interface java.util.List<T>
Specified by:
get in class java.util.AbstractList<T>
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the given index doesn't exist

size

public int size()
Returns the number of elements in this list.

Specified by:
size in interface java.util.Collection<T>
Specified by:
size in interface java.util.List<T>
Specified by:
size in class java.util.AbstractCollection<T>