org.javimmutable.collections.list
Class JImmutableLinkedStack<T>
java.lang.Object
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.
JImmutableLinkedStack
public JImmutableLinkedStack()
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.