|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--org.abora.white.xpp.basic.Heaper
|
+--org.abora.white.collection.tables.Pair
Sometimes you just want to pass around two things where the language only makes it
convenient to pass around one. I know that the proper object-oriented (or even
"structured") thing to do would be to create a type specific to the particular kind of
pair which is being used for a particular purpose. However, sometimes it just seems like
too much trouble. By using Pairs, we import the sins of Lisp. At least we don''t have
RPLACA and RPLACD. Unlike Lisp's cons cell's "car" and "cdr", we call our two parts the
"left" part and the "right" part. "pair(a,b)->left()" yields a and "pair(a,b)->right()"
yields b.
Give us feedback: Should Pairs be removed? Do you know of any justification for them other than a bad simulation of "multiple-return-values" (as in Common Lisp, Forth, Postscript)?
The Pair code is currently in a state of transition. Old code (which we have yet to fix) uses Pairs with NULLs in their parts. Pairs will be changed to outlaw this usage. "fetchLeft" and "fetchRight" exist to support this obsolete usage, but will be retired. Don't use them.
| Field Summary | |
protected Heaper |
leftPart
|
protected Heaper |
rightPart
|
| Constructor Summary | |
protected |
Pair(Heaper a,
Heaper b)
create a new pair |
protected |
Pair(Rcvr receiver)
|
| Method Summary | |
int |
actualHashForEqual()
Defined by subclasses to produce the value returned by hashForEqual. |
Heaper |
fetchLeft()
Returns the left part which obsoletely may be NULL |
Heaper |
fetchRight()
Returns the right part which obsoletely may be NULL |
boolean |
isEqual(Heaper other)
Return true if the two objects are equal. |
Heaper |
left()
Returns the left part. |
static Pair |
make(Heaper left,
Heaper right)
Create a new pair. |
static Pair |
pairWithNulls(Heaper left,
Heaper right)
Create a new pair. |
void |
printOn(java.io.PrintWriter oo)
This should rarely be overridden. |
Pair |
reversed()
Returns a new pair which is the left-right reversal of me. |
Heaper |
right()
Returns the right part. |
void |
sendSelfTo(Xmtr xmtr)
|
| Methods inherited from class org.abora.white.xpp.basic.Heaper |
destroy, destruct, equals, hashForEqual, printContentsOn, toString |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected Heaper leftPart
protected Heaper rightPart
| Constructor Detail |
protected Pair(Heaper a,
Heaper b)
protected Pair(Rcvr receiver)
| Method Detail |
public static Pair make(Heaper left,
Heaper right)
public static Pair pairWithNulls(Heaper left,
Heaper right)
public Heaper left()
public Heaper right()
public Heaper fetchLeft()
public Heaper fetchRight()
public Pair reversed()
public int actualHashForEqual()
Heaper
actualHashForEqual in class Heaperpublic boolean isEqual(Heaper other)
Heaper
isEqual in class Heaperpublic void printOn(java.io.PrintWriter oo)
Heaper
printOn in class Heaperpublic void sendSelfTo(Xmtr xmtr)
sendSelfTo in class Heaper
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||