| Modifier and Type | Method and Description |
|---|---|
ConsList<V> |
cons(V element)
Add an element to the head of the list.
|
boolean |
contains(V value)
Test for element.
|
V |
head()
Get the head of the list.
|
boolean |
isEmpty()
Test if empty.
|
Iterator<V> |
iterator()
Iterate through the elements in the list.
|
Iterator<V> |
reverseIterator()
Get the elements in reverse order.
|
boolean |
reverseVisit(ConditionalVisitor<V> visitor)
Visit all elements in reverse order until
visitor.visit() returns true; |
void |
reverseVisit(Visitor<V> visitor)
Visit all elements in reverse order.
|
int |
size()
Return the number of elements in the list.
|
CList<V> |
tail()
Get the rest of the list after the head.
|
void |
toCollection(Collection<V> collection)
Copy elements in list to collection in order.
|
String |
toString() |
boolean |
visit(ConditionalVisitor<V> visitor)
Visit each element in order until visit returns false.
|
void |
visit(Visitor<V> visitor)
Visit each element in order.
|
public ConsList<V> cons(V element)
CListpublic CList<V> tail()
CListgetFirst/getRest are not the most efficient
way to traverse the list elements.tail in interface CList<V>CList.iterator()public boolean contains(V value)
CListpublic void toCollection(Collection<V> collection)
CListtoCollection in interface CList<V>public void visit(Visitor<V> visitor)
CListpublic boolean visit(ConditionalVisitor<V> visitor)
CListIf the list is empty, returns true.
public boolean isEmpty()
AccessisEmpty() is guaranteed to be an O(1)
operation; it should always be used in preference to
size() == 0, as the latter may have cost up to O(n);public int size()
isEmpty() instead.public Iterator<V> reverseIterator()
AccessreverseIterator in interface Access<V>public void reverseVisit(Visitor<V> visitor)
AccessreverseVisit in interface Access<V>public boolean reverseVisit(ConditionalVisitor<V> visitor)
Accessvisitor.visit() returns true;reverseVisit in interface Access<V>visitor.visit() returned true;
otherwise falseCopyright © 2015. All rights reserved.