|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjsint.Pair
public class Pair
A Pair has two fields, first and rest (sometimes called car and cdr). The empty list is represented as a Pair, with both fields empty. (In Scheme it is an error to ask access those fields, but we don't complain.)
Field Summary | |
---|---|
static Pair |
EMPTY
The empty list. |
java.lang.Object |
first
The first element of the pair. |
java.lang.Object |
rest
The other element of the pair. |
Constructor Summary | |
---|---|
Pair(java.lang.Object first,
java.lang.Object rest)
Build a pair from two components. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object that)
Two pairs are equal if their first and rest fields are (equal?). |
java.lang.Object |
first()
Return the second element of a list. |
java.lang.Object |
getEltNover2(int n)
|
java.lang.Object |
getFirst()
Return the first element of a list. |
java.lang.Object |
getRest()
Return the second element of a list. |
int |
hashCode()
Lists that are .equals have the same .hashCode(). |
boolean |
isEmpty()
|
int |
length()
The length of a proper list. |
java.lang.Object |
listTail(int n)
Find the nth tail of a list, zero-based. |
java.lang.Object |
nth(int n)
Find the nth element of a list, zero-based |
java.lang.Object |
rest()
Return the second element of a list. |
java.lang.Object |
reverse()
Reverse the elements of a list. |
java.lang.Object |
second()
Return the second element of a list. |
java.lang.Object |
setEltNover2(int n,
java.lang.Object v)
|
java.lang.Object |
setFirst(java.lang.Object x)
Set the first element of a list. |
java.lang.Object |
setRest(java.lang.Object x)
Return the second element of a list. |
java.lang.StringBuffer |
stringifyPair(boolean quoted,
java.lang.StringBuffer buf)
Build up a String representation of the Pair in a StringBuffer. |
java.lang.Object |
third()
Return the third element of a list. |
java.lang.String |
toString()
Return a String representation of the pair. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.lang.Object first
public java.lang.Object rest
public static final Pair EMPTY
Constructor Detail |
---|
public Pair(java.lang.Object first, java.lang.Object rest)
Method Detail |
---|
public java.lang.Object getFirst()
getFirst
in interface SchemePair
public java.lang.Object getRest()
getRest
in interface SchemePair
public java.lang.Object setFirst(java.lang.Object x)
setFirst
in interface SchemePair
public java.lang.Object setRest(java.lang.Object x)
setRest
in interface SchemePair
public java.lang.Object first()
first
in interface SchemePair
public java.lang.Object rest()
rest
in interface SchemePair
public java.lang.Object second()
second
in interface SchemePair
public java.lang.Object third()
third
in interface SchemePair
public java.lang.Object reverse()
reverse
in interface SchemePair
public int hashCode()
hashCode
in interface SchemePair
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object that)
equals
in interface SchemePair
equals
in class java.lang.Object
public java.lang.String toString()
toString
in interface SchemePair
toString
in class java.lang.Object
public java.lang.StringBuffer stringifyPair(boolean quoted, java.lang.StringBuffer buf)
stringifyPair
in interface SchemePair
public int length()
length
in interface SchemePair
public java.lang.Object nth(int n)
nth
in interface SchemePair
public java.lang.Object listTail(int n)
listTail
in interface SchemePair
public boolean isEmpty()
isEmpty
in interface SchemePair
public java.lang.Object getEltNover2(int n)
getEltNover2
in interface SchemePair
public java.lang.Object setEltNover2(int n, java.lang.Object v)
setEltNover2
in interface SchemePair
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |