|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectxtc.util.Pair<T>
public class Pair<T>
Implementation of a pair. Pairs are used to construct singly-linked lists, not unlike cons cells in Scheme. Generally, pairs should be treated as immutable data structures. In particular, a pair must not be modified if it is memoized by a Rats!-generated parser.
| Field Summary | |
|---|---|
static Pair |
EMPTY
The pair representing the empty list. |
| Constructor Summary | |
|---|---|
Pair(T head)
Create a new pair. |
|
Pair(T head,
Pair<T> tail)
Create a new pair. |
|
| Method Summary | ||
|---|---|---|
Pair<T> |
add(T element)
Add the specified element to the list starting at this pair. |
|
void |
addTo(java.util.List<? super T> l)
Add the values of the list starting at this pair in order to the specified Java collections framework list. |
|
Pair<T> |
append(Pair<T> tail)
Set the tail of a copy of this list's last pair to the specified value. |
|
Pair<T> |
combine(Pair<T> list)
Combine the elements on the list starting at this pair with the elements on the list starting at the specified pair. |
|
boolean |
consists()
Determine whether the list starting at this pair consists of no elements. |
|
boolean |
consists(java.lang.Object... os)
Determine whether the list starting at this pair consists of the specified objects. |
|
boolean |
consists(java.lang.Object o)
Determine whether the list starting at this pair consists of the specified object. |
|
boolean |
consists(java.lang.Object o1,
java.lang.Object o2)
Determine whether the list starting at this pair consists of the specified two objects. |
|
boolean |
consists(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3)
Determine whether the list starting at this pair consists of the specified three objects. |
|
boolean |
consists(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4)
Determine whether the list starting at this pair consists of the specified four objects. |
|
boolean |
consists(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5)
Determine whether the list starting at this pair consists of the specified five objects. |
|
boolean |
contains(java.lang.Object o)
Determine whether the list starting at this pair contains the specified element. |
|
static
|
empty()
Get the canoncial empty pair. |
|
boolean |
equals(java.lang.Object o)
Determine whether the list starting at this pair equals the specified object. |
|
T |
get(int index)
Get the element at the specified index of the list starting at this pair. |
|
int |
hashCode()
Get a hashcode for the list starting at this pair. |
|
T |
head()
Get the head. |
|
Pair<T> |
intersect(Pair<T> list)
Intersect the elements on the list starting at this pair with the elements on the list starting at the specified pair. |
|
boolean |
isEmpty()
Determine whether the list starting at this pair is empty. |
|
java.util.Iterator<T> |
iterator()
Get an iterator over the values of the list starting at this pair. |
|
java.util.List<T> |
list()
Convert the list starting at this pair into a Java collections framework list. |
|
Pair<T> |
reverse()
Reverse the list starting at this pair in place. |
|
T |
set(int index,
T element)
Replace the element at the specified index of the list starting at this pair. |
|
T |
setHead(T head)
Set the head. |
|
void |
setLastTail(Pair<T> tail)
Set the tail of this list's last pair to the specified value. |
|
Pair<T> |
setTail(Pair<T> tail)
Set the tail. |
|
int |
size()
Get the size of the list starting at this pair. |
|
Pair<T> |
subtract(Pair<T> list)
Subtract the elements on the list starting at the specified list from the elements on the list starting at this pair. |
|
Pair<T> |
tail()
Get the tail. |
|
java.lang.String |
toString()
Get a string representation for the list starting at this pair. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Pair EMPTY
| Constructor Detail |
|---|
public Pair(T head)
head - The head.
public Pair(T head,
Pair<T> tail)
head - The head.tail - The tail.
java.lang.NullPointerException - Signals that tail is null.| Method Detail |
|---|
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - The object.
true if the list starting at this pair
equals the object.public boolean isEmpty()
true if the list is empty.public T head()
java.lang.IllegalStateException - Signals that this pair represents the empty list.public T setHead(T head)
head - The new head.
java.lang.IllegalStateException - Signals that this pair represents the empty list.public Pair<T> tail()
java.lang.IllegalStateException - Signals that this pair represents the empty list.public Pair<T> setTail(Pair<T> tail)
tail - The new tail.
java.lang.NullPointerException - Signals that tail is null.
java.lang.IllegalStateException - Signals that this pair represents the empty list.public T get(int index)
index - The element's index.
java.lang.IndexOutOfBoundsException - Signals an invalid index.
public T set(int index,
T element)
index - The element's index.element - The new element.
java.lang.IndexOutOfBoundsException - Signals an invalid index.public int size()
public boolean contains(java.lang.Object o)
null, the implementation invokes
equals() on the element.
o - The element.
true if the list starting at this pair
contains the element.public boolean consists()
true if the list starting at this pair
consists of no elements.public boolean consists(java.lang.Object o)
null, the implementation invokes
equals() on the object.
o - The object.
true if the list starting at this pair
consists of the object.
public boolean consists(java.lang.Object o1,
java.lang.Object o2)
null, the implementation invokes
equals() on the object.
o1 - The first object.o2 - The second object.
true if the list starting at this pair
consists of the two objects.
public boolean consists(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3)
null, the implementation invokes
equals() on the object.
o1 - The first object.o2 - The second object.o3 - The third object.
true if the list starting at this pair
consists of the three objects.
public boolean consists(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4)
null, the implementation invokes
equals() on the object.
o1 - The first object.o2 - The second object.o3 - The third object.o4 - The fourth object.
true if the list starting at this pair
consists of the four objects.
public boolean consists(java.lang.Object o1,
java.lang.Object o2,
java.lang.Object o3,
java.lang.Object o4,
java.lang.Object o5)
null, the implementation invokes
equals() on the object.
o1 - The first object.o2 - The second object.o3 - The third object.o4 - The fourth object.o5 - The fifth object.
true if the list starting at this pair
consists of the five objects.public boolean consists(java.lang.Object... os)
null, the implementation invokes
equals() on the object.
os - The objects.
true if the list starting at this pair
consists of the specified objects.public java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>public Pair<T> reverse()
public Pair<T> add(T element)
element - The element.
java.lang.IllegalStateException - Signals that this pair represent
the empty list.public void setLastTail(Pair<T> tail)
tail - The new tail.
java.lang.NullPointerException - Signals that tail is
null.
java.lang.IllegalStateException - Signals that this pair represents
the empty list.append(Pair)public Pair<T> append(Pair<T> tail)
tail - The new tail.
java.lang.NullPointerException - Signals that tail is
null.setLastTail(Pair)public Pair<T> combine(Pair<T> list)
list - The other list.
public Pair<T> intersect(Pair<T> list)
list - The other list.
public Pair<T> subtract(Pair<T> list)
list - The list to subtract.
public void addTo(java.util.List<? super T> l)
l - The list.public java.util.List<T> list()
public java.lang.String toString()
toString in class java.lang.Objectpublic static final <T> Pair<T> empty()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||