harpoon.Util
Class Tuple

java.lang.Object
  extended by harpoon.Util.Tuple
All Implemented Interfaces:
Serializable, Comparable
Direct Known Subclasses:
InterfaceListPointer, StringPointer, UndefinedPointer

public class Tuple
extends Object
implements Comparable, Serializable

A Tuple is an ordered list of objects that works properly in Hashtables & etc. Tuples may have null elements. Tuples are Comparable iff the objects in the elements array are Comparable.

Version:
$Id: Tuple.java,v 1.4 2004/02/08 01:56:15 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
Serialized Form

Constructor Summary
Tuple(Object[] elements)
          Creates a Tuple.
Tuple(Object[] elements, Comparator objcmp)
          Creates a Comparable Tuple which will use the specified Comparator to do object comparisons.
 
Method Summary
 List asList()
          Returns an unmodifiable list view of the Tuple.
 int compareTo(Object o)
          Does an element-by-element comparison of two Tuples.
 boolean equals(Object obj)
          Does an element-by-element comparison of two Tuples.
 int hashCode()
          Synthesizes a hashcode from the hashcodes of the elements.
 Object proj(int i)
          Projects an element of the Tuple.
 String toString()
          Returns a human-readable description of this Tuple.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tuple

public Tuple(Object[] elements)
Creates a Tuple.


Tuple

public Tuple(Object[] elements,
             Comparator objcmp)
Creates a Comparable Tuple which will use the specified Comparator to do object comparisons.

Method Detail

proj

public Object proj(int i)
Projects an element of the Tuple.


asList

public List asList()
Returns an unmodifiable list view of the Tuple.


toString

public String toString()
Returns a human-readable description of this Tuple.

Overrides:
toString in class Object

hashCode

public int hashCode()
Synthesizes a hashcode from the hashcodes of the elements.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Does an element-by-element comparison of two Tuples.

Overrides:
equals in class Object

compareTo

public int compareTo(Object o)
Does an element-by-element comparison of two Tuples. Inconsistent with equals() only if the underlying comparator is. Shorter tuples are compared as less than longer tuples.

Specified by:
compareTo in interface Comparable