org.javimmutable.collections
Interface JImmutableStack<T>

Type Parameters:
T -
All Superinterfaces:
Cursorable<T>, Insertable<T>, Iterable<T>, Sequence<T>
All Known Implementing Classes:
JImmutableLinkedStack

@Immutable
public interface JImmutableStack<T>
extends Insertable<T>, Sequence<T>, Cursorable<T>, Iterable<T>

Interface for objects that store values in LIFO form. Elements are always added at the front of the list so elements are traversed in reverse order.


Method Summary
 T getHead()
          Accesses the first value in the List.
 JImmutableStack<T> getTail()
          Accesses the rest of the List (i.e.
 JImmutableStack<T> insert(T value)
          Returns a new list containing the value before the element returned by getHead().
 boolean isEmpty()
          Determines if this is the end of the Sequence.
 JImmutableStack<T> remove()
          Returns a list without the element returned by getHead().
 
Methods inherited from interface org.javimmutable.collections.Cursorable
cursor
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

isEmpty

boolean isEmpty()
Description copied from interface: Sequence
Determines if this is the end of the Sequence. When try the Sequence is empty and getHead() cannot be called. getTail() can still be called but will always return an empty Sequence once isEmpty() returns true.

Specified by:
isEmpty in interface Sequence<T>
Returns:

getHead

T getHead()
Accesses the first value in the List.

Specified by:
getHead in interface Sequence<T>
Returns:

getTail

@Nonnull
JImmutableStack<T> getTail()
Accesses the rest of the List (i.e. the entry after the head entry).

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

insert

@Nonnull
JImmutableStack<T> insert(@Nullable
                                  T value)
Returns a new list containing the value before the element returned by getHead().

Specified by:
insert in interface Insertable<T>
Parameters:
value -
Returns:

remove

@Nonnull
JImmutableStack<T> remove()
Returns a list without the element returned by getHead().

Returns:


Copyright © 2014 Burton Computer Corporation. All rights reserved.