Class List.Buffer<A>
java.lang.Object
fj.data.List.Buffer<A>
- All Implemented Interfaces:
Iterable<A>
A mutable, singly linked list. This structure should be used very sparingly, in favour
of the
immutable singly linked list structure.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppends the given list to this buffer.private voidcopy()static <A> List.Buffer<A> empty()An empty buffer.static <A> List.Buffer<A> Constructs a buffer from the given list.booleanisEmpty()Returnstrueif this buffer is empty,falseotherwise.static <A> List.Buffer<A> iterableBuffer(Iterable<A> i) Takes the given iterable to a buffer.iterator()Returns an iterator for this buffer.prependToList(List<A> as) Prepends the elements of this buffer to the given list.Appends (snoc) the given element to this buffer to produce a new buffer.Projects an immutable collection of this buffer.toList()Returns an immutable list projection of this buffer.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
start
-
tail
-
exported
private boolean exported
-
-
Constructor Details
-
Buffer
public Buffer()
-
-
Method Details
-
iterator
-
snoc
Appends (snoc) the given element to this buffer to produce a new buffer.- Parameters:
a- The element to append to this buffer.- Returns:
- This buffer.
-
append
Appends the given list to this buffer.- Parameters:
as- The list to append to this buffer.- Returns:
- This buffer.
-
prependToList
-
isEmpty
public boolean isEmpty()Returnstrueif this buffer is empty,falseotherwise. -
toList
-
toCollection
Projects an immutable collection of this buffer.- Returns:
- An immutable collection of this buffer.
-
empty
-
fromList
Constructs a buffer from the given list.- Parameters:
as- The list to construct a buffer with.- Returns:
- A buffer from the given list.
-
iterableBuffer
Takes the given iterable to a buffer.- Parameters:
i- The iterable to take to a buffer.- Returns:
- A buffer from the given iterable.
-
copy
private void copy()
-