Package fj.data
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 void
copy()
static <A> List.Buffer
<A> empty()
An empty buffer.static <A> List.Buffer
<A> Constructs a buffer from the given list.boolean
isEmpty()
Returnstrue
if this buffer is empty,false
otherwise.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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
start
-
tail
-
exported
private boolean exported
-
-
Constructor Details
-
Buffer
public Buffer()
-
-
Method Details
-
iterator
Returns an iterator for this buffer. This method exists to permit the use in afor
-each loop. -
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
Prepends the elements of this buffer to the given list.- Parameters:
as
- the list to which elements are prepended.
-
isEmpty
public boolean isEmpty()Returnstrue
if this buffer is empty,false
otherwise. -
toList
Returns an immutable list projection of this buffer. Modifications to the underlying buffer will not be reflected in returned lists.- Returns:
- An immutable list projection of this buffer.
-
toCollection
Projects an immutable collection of this buffer.- Returns:
- An immutable collection of this buffer.
-
empty
An empty buffer.- Returns:
- An empty buffer.
-
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()
-