|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfj.data.NonEmptyList<A>
public final class NonEmptyList<A>
Provides an in-memory, immutable, singly linked list with total head
and tail
.
Field Summary | |
---|---|
A |
head
The first element of this linked list. |
List<A> |
tail
This list without the first element. |
Method Summary | ||
---|---|---|
NonEmptyList<A> |
append(NonEmptyList<A> as)
Appends the given list to this list. |
|
|
bind(F<A,NonEmptyList<B>> f)
Binds the given function across each element of this list with a final join. |
|
NonEmptyList<A> |
cons(A a)
Prepend the given value to this list. |
|
static
|
fromList(List<A> as)
Returns a potential non-empty list from the given list. |
|
Iterator<A> |
iterator()
Returns an iterator for this non-empty list. |
|
|
map(F<A,B> f)
Maps the given function across this list. |
|
|
mapTails(F<NonEmptyList<A>,B> f)
Maps the given function across the tails of this list (comonad pattern). |
|
static
|
nel()
Returns a function that puts an element into a non-empty list. |
|
static
|
nel(A head)
Return a non-empty list with the given value. |
|
static
|
nel(A head,
List<A> tail)
Return a non-empty list with the given head and tail. |
|
NonEmptyList<NonEmptyList<A>> |
sublists()
Returns a NonEmptyList of the sublists of this list. |
|
NonEmptyList<NonEmptyList<A>> |
tails()
Returns a NonEmptyList of the tails of this list. |
|
Collection<A> |
toCollection()
Projects an immutable collection of this non-empty list. |
|
static
|
toList_()
Returns a function that takes a non-empty list to a list. |
|
List<A> |
toList()
Returns a List projection of this list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final A head
public final List<A> tail
Method Detail |
---|
public Iterator<A> iterator()
for
-each loop.
iterator
in interface Iterable<A>
public NonEmptyList<A> cons(A a)
a
- The value to prepend.
public NonEmptyList<A> append(NonEmptyList<A> as)
as
- The list to append.
public <B> NonEmptyList<B> map(F<A,B> f)
f
- The function to map across this list.
public <B> NonEmptyList<B> bind(F<A,NonEmptyList<B>> f)
f
- The function to apply to each element of this list.
public NonEmptyList<NonEmptyList<A>> sublists()
public NonEmptyList<NonEmptyList<A>> tails()
public <B> NonEmptyList<B> mapTails(F<NonEmptyList<A>,B> f)
f
- The function to map across the tails of this list.
public List<A> toList()
List
projection of this list.
List
projection of this list.public Collection<A> toCollection()
public static <A> F<NonEmptyList<A>,List<A>> toList_()
public static <A> NonEmptyList<A> nel(A head, List<A> tail)
head
- The first element of the new list.tail
- The remaining elements of the new list.
public static <A> NonEmptyList<A> nel(A head)
head
- The value in the non-empty list.
public static <A> F<A,NonEmptyList<A>> nel()
public static <A> Option<NonEmptyList<A>> fromList(List<A> as)
as
- The list to construct a potential non-empty list with.
|
Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg This software is released under an open source BSD licence. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |