sleep.engine.types
Class ListContainer

java.lang.Object
  extended by sleep.engine.types.ListContainer
All Implemented Interfaces:
Serializable, ScalarArray

public class ListContainer
extends Object
implements ScalarArray

A linked list backing for Sleep Arrays. Most array ops are better off with this type of backing

See Also:
Serialized Form

Field Summary
protected  List values
           
 
Constructor Summary
ListContainer()
           
ListContainer(Collection initialValues)
          initial values must be a collection of Scalar's
ListContainer(List list)
           
 
Method Summary
 Scalar add(Scalar value, int index)
          add an element to the array at the specified index
 Scalar getAt(int index)
          get an element at the specified index
 Scalar pop()
          remove the topmost element from the array
 Scalar push(Scalar value)
          add an element onto the end of the array
 Scalar remove(int index)
          remove an element at the specified index
 void remove(Scalar key)
          remove all elements with the same identity as the specified scalar
 Iterator scalarIterator()
          return an iterator
 int size()
          return the size of the array
 void sort(Comparator compare)
          sort this array with the specified comparator
 ScalarArray sublist(int from, int to)
          return a view into the array, ideally one that uses the same backing store
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

values

protected List values
Constructor Detail

ListContainer

public ListContainer()

ListContainer

public ListContainer(List list)

ListContainer

public ListContainer(Collection initialValues)
initial values must be a collection of Scalar's

Method Detail

sublist

public ScalarArray sublist(int from,
                           int to)
Description copied from interface: ScalarArray
return a view into the array, ideally one that uses the same backing store

Specified by:
sublist in interface ScalarArray

pop

public Scalar pop()
Description copied from interface: ScalarArray
remove the topmost element from the array

Specified by:
pop in interface ScalarArray

push

public Scalar push(Scalar value)
Description copied from interface: ScalarArray
add an element onto the end of the array

Specified by:
push in interface ScalarArray

size

public int size()
Description copied from interface: ScalarArray
return the size of the array

Specified by:
size in interface ScalarArray

sort

public void sort(Comparator compare)
Description copied from interface: ScalarArray
sort this array with the specified comparator

Specified by:
sort in interface ScalarArray

getAt

public Scalar getAt(int index)
Description copied from interface: ScalarArray
get an element at the specified index

Specified by:
getAt in interface ScalarArray

remove

public void remove(Scalar key)
Description copied from interface: ScalarArray
remove all elements with the same identity as the specified scalar

Specified by:
remove in interface ScalarArray

remove

public Scalar remove(int index)
Description copied from interface: ScalarArray
remove an element at the specified index

Specified by:
remove in interface ScalarArray

scalarIterator

public Iterator scalarIterator()
Description copied from interface: ScalarArray
return an iterator

Specified by:
scalarIterator in interface ScalarArray

add

public Scalar add(Scalar value,
                  int index)
Description copied from interface: ScalarArray
add an element to the array at the specified index

Specified by:
add in interface ScalarArray

toString

public String toString()
Overrides:
toString in class Object