edu.mit.csail.sdg.alloy4
Class JoinableList<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by edu.mit.csail.sdg.alloy4.JoinableList<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>

public final class JoinableList<E>
extends java.util.AbstractList<E>
implements java.io.Serializable

Immutable; implements a list where it is combine them; null values are NOT allowed.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
JoinableList()
          Construct an empty list.
JoinableList(E item)
          Construct a list containing a single item, or return an empty list if item==null.
 
Method Summary
 E get(int i)
          Return the i-th element
 JoinableList<E> make(E newItem)
          Returns a list that represents the result of appending newItem onto this list; if newItem==null we return this list as-is.
 JoinableList<E> make(JoinableList<E> that)
          Returns a list that represents the concatenation of this list and that list.
 E pick()
          If the list if nonempty, arbitrarily return one of the item, otherwise throw ArrayIndexOutOfBoundsException.
 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
 

Constructor Detail

JoinableList

public JoinableList()
Construct an empty list.


JoinableList

public JoinableList(E item)
Construct a list containing a single item, or return an empty list if item==null.

Method Detail

make

public JoinableList<E> make(JoinableList<E> that)
Returns a list that represents the concatenation of this list and that list.


make

public JoinableList<E> make(E newItem)
Returns a list that represents the result of appending newItem onto this list; if newItem==null we return this list as-is.


pick

public E pick()
If the list if nonempty, arbitrarily return one of the item, otherwise throw ArrayIndexOutOfBoundsException.


get

public E get(int i)
Return the i-th element

Specified by:
get in interface java.util.List<E>
Specified by:
get in class java.util.AbstractList<E>
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<E>
Specified by:
size in interface java.util.List<E>
Specified by:
size in class java.util.AbstractCollection<E>