Copyright 2008 - 2010 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg

This software is released under an open source BSD licence.

fj.data
Class List.Buffer<A>

java.lang.Object
  extended by fj.data.List.Buffer<A>
All Implemented Interfaces:
Iterable<A>
Enclosing class:
List<A>

public static final class List.Buffer<A>
extends Object
implements Iterable<A>

A mutable, singly linked list. This structure should be used very sparingly, in favour of the immutable singly linked list structure.


Constructor Summary
List.Buffer()
           
 
Method Summary
 List.Buffer<A> append(List<A> as)
          Appends the given buffer 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.
static
<A> List.Buffer<A>
iterableBuffer(Iterable<A> i)
          Takes the given iterable to a buffer.
 Iterator<A> iterator()
          Returns an iterator for this buffer.
 List.Buffer<A> snoc(A a)
          Appends (snoc) the given element to this buffer to produce a new buffer.
 Collection<A> toCollection()
          Projects an immutable collection of this buffer.
 List<A> 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
 

Constructor Detail

List.Buffer

public List.Buffer()
Method Detail

iterator

public Iterator<A> iterator()
Returns an iterator for this buffer. This method exists to permit the use in a for-each loop.

Specified by:
iterator in interface Iterable<A>
Returns:
A iterator for this buffer.

snoc

public List.Buffer<A> snoc(A a)
Appends (snoc) the given element to this buffer to produce a new buffer.

Parameters:
a - The element to append to this buffer.
Returns:
A new buffer with the given element appended.

append

public List.Buffer<A> append(List<A> as)
Appends the given buffer to this buffer.

Parameters:
as - The buffer to append to this one.
Returns:
A new buffer that has appended the given buffer.

toList

public List<A> 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

public Collection<A> toCollection()
Projects an immutable collection of this buffer.

Returns:
An immutable collection of this buffer.

empty

public static <A> List.Buffer<A> empty()
An empty buffer.

Returns:
An empty buffer.

fromList

public static <A> List.Buffer<A> fromList(List<A> as)
Constructs a buffer from the given list.

Parameters:
as - The list to construct a buffer with.
Returns:
A buffer from the given list.

iterableBuffer

public static <A> List.Buffer<A> iterableBuffer(Iterable<A> i)
Takes the given iterable to a buffer.

Parameters:
i - The iterable to take to a buffer.
Returns:
A buffer from the given iterable.

Copyright 2008 - 2010 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg

This software is released under an open source BSD licence.