edu.mit.csail.sdg.alloy4viz
Class AlloyTuple

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4viz.AlloyTuple
All Implemented Interfaces:
java.lang.Comparable<AlloyTuple>

public final class AlloyTuple
extends java.lang.Object
implements java.lang.Comparable<AlloyTuple>

Immutable; represents an Alloy tuple.

Thread Safety: Can be called only by the AWT event thread.


Constructor Summary
AlloyTuple(AlloyAtom... atoms)
          Creates a new AlloyTuple containing the atoms specified by the list; atoms.size() must be 2 or above.
AlloyTuple(java.util.List<AlloyAtom> atoms)
          Creates a new AlloyTuple containing the atoms specified by the list; atoms.size() must be 2 or above.
 
Method Summary
 int compareTo(AlloyTuple that)
          Two tuples are first compared based on length; if the length is the same, we compare atom-by-atom.
 boolean equals(java.lang.Object other)
          Two tuples are equal if they have the same atoms in the same order.
 int getArity()
          Returns the arity of this AlloyTuple.
 java.util.List<AlloyAtom> getAtoms()
          Returns an unmodifiable list of the AlloyAtoms in this AlloyTuple.
 AlloyAtom getEnd()
          Returns the last AlloyAtom in this AlloyTuple.
 AlloyAtom getStart()
          Returns the first AlloyAtom in this AlloyTuple.
 int hashCode()
          Compute a hash code based on the list of atoms.
 ConstList<AlloyAtom> project(java.util.Collection<java.lang.Integer> columns)
          Project this tuple and return an unmodifiable list of remaining atoms (after removing zero or more columns)
 AlloyTuple reverse()
          Returns a new AlloyTuple whose list of atoms is the same but in reverse.
 java.lang.String toString()
          Provides a human-readable description of this AlloyTuple.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlloyTuple

public AlloyTuple(java.util.List<AlloyAtom> atoms)
Creates a new AlloyTuple containing the atoms specified by the list; atoms.size() must be 2 or above.


AlloyTuple

public AlloyTuple(AlloyAtom... atoms)
Creates a new AlloyTuple containing the atoms specified by the list; atoms.size() must be 2 or above.

Method Detail

project

public ConstList<AlloyAtom> project(java.util.Collection<java.lang.Integer> columns)
Project this tuple and return an unmodifiable list of remaining atoms (after removing zero or more columns)

Parameters:
columns - - the collection of columns to remove (0 is the first column, 1 is the second column...)

getArity

public int getArity()
Returns the arity of this AlloyTuple.


getAtoms

public java.util.List<AlloyAtom> getAtoms()
Returns an unmodifiable list of the AlloyAtoms in this AlloyTuple.


getStart

public AlloyAtom getStart()
Returns the first AlloyAtom in this AlloyTuple.


getEnd

public AlloyAtom getEnd()
Returns the last AlloyAtom in this AlloyTuple.


reverse

public AlloyTuple reverse()
Returns a new AlloyTuple whose list of atoms is the same but in reverse.


toString

public java.lang.String toString()
Provides a human-readable description of this AlloyTuple.

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(AlloyTuple that)
Two tuples are first compared based on length; if the length is the same, we compare atom-by-atom.
We guarantee x.equals(y) iff x.compareTo(y)==0

Specified by:
compareTo in interface java.lang.Comparable<AlloyTuple>

equals

public boolean equals(java.lang.Object other)
Two tuples are equal if they have the same atoms in the same order.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Compute a hash code based on the list of atoms.

Overrides:
hashCode in class java.lang.Object