| Modifier and Type | Method and Description |
|---|---|
CList<V> |
cons(V element)
Add an element to the head of the list.
|
boolean |
contains(V element)
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.
|
CList<V> |
removeFirst() |
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()
Get the number of elements in the collection.
|
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.
|
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 CList<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 element)
CListpublic Iterator<V> iterator()
CListpublic Iterator<V> reverseIterator()
AccessreverseIterator in interface Access<V>public void visit(Visitor<V> visitor)
CListpublic boolean visit(ConditionalVisitor<V> visitor)
CListIf the list is empty, returns true.
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 falsepublic void toCollection(Collection<V> collection)
CListtoCollection in interface CList<V>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);Copyright © 2015. All rights reserved.