org.javimmutable.collections.list
Class JImmutableLinkedStack<T>

java.lang.Object
  extended by org.javimmutable.collections.list.JImmutableLinkedStack<T>
Type Parameters:
T -
All Implemented Interfaces:
Iterable<T>, Cursorable<T>, Insertable<T>, JImmutableStack<T>, Sequence<T>

@Immutable
public abstract class JImmutableLinkedStack<T>
extends Object
implements JImmutableStack<T>

Singly linked list implementation of PersistentList that stores and retrieves values in the reverse order of the corresponding add() method calls. If forward or random access to stored values is required use PersistentArrayList or PersistentTreeList instead but this class is significantly faster when its limitations are acceptable.


Constructor Summary
JImmutableLinkedStack()
           
 
Method Summary
 boolean equals(Object o)
           
abstract  JImmutableLinkedStack<T> getTail()
          Accesses the rest of the List (i.e.
 int hashCode()
           
abstract  JImmutableLinkedStack<T> insert(T value)
          Returns a new list containing the value before the element returned by getHead().
 Iterator<T> iterator()
           
 List<T> makeList()
           
static
<T> JImmutableLinkedStack<T>
of()
           
static
<T> JImmutableLinkedStack<T>
of(List<T> values)
           
static
<T> JImmutableLinkedStack<T>
of(T... values)
           
static
<T> JImmutableLinkedStack<T>
of(T value)
           
 JImmutableStack<T> remove()
          Returns a list without the element returned by getHead().
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.javimmutable.collections.JImmutableStack
getHead, isEmpty
 
Methods inherited from interface org.javimmutable.collections.Cursorable
cursor
 

Constructor Detail

JImmutableLinkedStack

public JImmutableLinkedStack()
Method Detail

of

public static <T> JImmutableLinkedStack<T> of()

of

public static <T> JImmutableLinkedStack<T> of(T value)

of

public static <T> JImmutableLinkedStack<T> of(List<T> values)

of

public static <T> JImmutableLinkedStack<T> of(T... values)

insert

@Nonnull
public abstract JImmutableLinkedStack<T> insert(@Nullable
                                                        T value)
Description copied from interface: JImmutableStack
Returns a new list containing the value before the element returned by getHead().

Specified by:
insert in interface Insertable<T>
Specified by:
insert in interface JImmutableStack<T>
Returns:

getTail

@Nonnull
public abstract JImmutableLinkedStack<T> getTail()
Description copied from interface: JImmutableStack
Accesses the rest of the List (i.e. the entry after the head entry).

Specified by:
getTail in interface JImmutableStack<T>
Specified by:
getTail in interface Sequence<T>
Returns:

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>

makeList

public List<T> makeList()

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

remove

@Nonnull
public JImmutableStack<T> remove()
Description copied from interface: JImmutableStack
Returns a list without the element returned by getHead().

Specified by:
remove in interface JImmutableStack<T>
Returns:


Copyright © 2014 Burton Computer Corporation. All rights reserved.