|
|||||||||
| Home >> All >> [ silk overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
silk
Class Pair

java.lang.Objectsilk.Pair
- All Implemented Interfaces:
- java.io.Serializable
- public class Pair
- extends java.lang.Object
- implements java.io.Serializable
- extends java.lang.Object
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. |
private boolean |
equalsFirst(Pair that)
|
java.lang.Object |
getEltNover2(int n)
|
int |
hashCode()
Lists that are (equal?) should 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 |
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.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 |
first
public java.lang.Object first
- The first element of the pair.
rest
public java.lang.Object rest
- The other element of the pair.
EMPTY
public static final Pair EMPTY
- The empty list. It's first and rest fields are also EMPTY.
| Constructor Detail |
Pair
public Pair(java.lang.Object first, java.lang.Object rest)
- Build a pair from two components.
| Method Detail |
second
public java.lang.Object second()
- Return the second element of a list.
third
public java.lang.Object third()
- Return the third element of a list.
reverse
public java.lang.Object reverse()
- Reverse the elements of a list.
hashCode
public int hashCode()
- Lists that are (equal?) should have the same hashCode.
equals
public boolean equals(java.lang.Object that)
- Two pairs are equal if their first and rest fields are equal.
equalsFirst
private boolean equalsFirst(Pair that)
toString
public java.lang.String toString()
- Return a String representation of the pair.
stringifyPair
public java.lang.StringBuffer stringifyPair(boolean quoted, java.lang.StringBuffer buf)
- Build up a String representation of the Pair in a StringBuffer.
length
public int length()
- The length of a proper list.
nth
public java.lang.Object nth(int n)
- Find the nth element of a list, zero-based
listTail
public java.lang.Object listTail(int n)
- Find the nth tail of a list, zero-based.
isEmpty
public boolean isEmpty()
getEltNover2
public java.lang.Object getEltNover2(int n)
setEltNover2
public java.lang.Object setEltNover2(int n, java.lang.Object v)
|
|||||||||
| Home >> All >> [ silk overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
silk.Pair