public static final class List.Buffer<A>
extends java.lang.Object
implements java.lang.Iterable<A>
immutable singly linked list structure
.Constructor and Description |
---|
Buffer() |
Modifier and Type | Method and Description |
---|---|
List.Buffer<A> |
append(List<A> as)
Appends the given list to this buffer.
|
static <A> List.Buffer<A> |
empty()
An empty buffer.
|
static <A> List.Buffer<A> |
fromList(List<A> as)
Constructs a buffer from the given list.
|
boolean |
isEmpty()
Returns
true if this buffer is empty, false otherwise. |
static <A> List.Buffer<A> |
iterableBuffer(java.lang.Iterable<A> i)
Takes the given iterable to a buffer.
|
java.util.Iterator<A> |
iterator()
Returns an iterator for this buffer.
|
List<A> |
prependToList(List<A> as)
Prepends the elements of this buffer to the given list.
|
List.Buffer<A> |
snoc(A a)
Appends (snoc) the given element to this buffer to produce a new buffer.
|
java.util.Collection<A> |
toCollection()
Projects an immutable collection of this buffer.
|
List<A> |
toList()
Returns an immutable list projection of this buffer.
|
public java.util.Iterator<A> iterator()
for
-each loop.iterator
in interface java.lang.Iterable<A>
public List.Buffer<A> snoc(A a)
a
- The element to append to this buffer.public List.Buffer<A> append(List<A> as)
as
- The list to append to this buffer.public List<A> prependToList(List<A> as)
as
- the list to which elements are prepended.public boolean isEmpty()
true
if this buffer is empty, false
otherwise.public List<A> toList()
public java.util.Collection<A> toCollection()
public static <A> List.Buffer<A> empty()
public static <A> List.Buffer<A> fromList(List<A> as)
as
- The list to construct a buffer with.public static <A> List.Buffer<A> iterableBuffer(java.lang.Iterable<A> i)
i
- The iterable to take to a buffer.