edu.mit.csail.sdg.alloy4compiler.sim
Class SimTuple

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4compiler.sim.SimTuple
All Implemented Interfaces:
java.lang.Iterable<SimAtom>

public final class SimTuple
extends java.lang.Object
implements java.lang.Iterable<SimAtom>

Immutable; represents a tuple.

Thread Safety: Safe.


Method Summary
 SimTuple append(SimAtom atom)
          Append the given atom to the back of this tuple, then return the resulting new Tuple.
 int arity()
          Returns the arity of this tuple.
 boolean equals(java.lang.Object that)
          
 SimAtom get(int i)
          Return the i-th atom from this tuple.
 boolean has(SimAtom atom)
          Returns true if this tuple contains at least one occurrence of the given atom.
 int hashCode()
          
 SimAtom head()
          Returns the first atom of this tuple.
 SimTuple head(int n)
          Returns the subtuple containing the first n atoms (n must be between 1 and arity)
 java.util.Iterator<SimAtom> iterator()
          
 SimTuple join(SimTuple that)
          Return the relational join of this tuple and that tuple; throws an exception if the join point doesn't match or if both sides are unary.
static SimTuple make(java.util.List<SimAtom> list)
          Construct the n-ary tuple; throws an exception if the given list is empty.
static SimTuple make(SimAtom atom)
          Construct the unary tuple containing the given atom.
static SimTuple make(SimAtom a, SimAtom b)
          Construct the binary tuple (a,b)
static SimTuple make(java.lang.String atom)
          Construct the unary tuple containing the given atom.
static SimTuple make(java.lang.String[] atoms)
          Construct the tuple containing the given list of atoms; the list must not be empty.
 SimTuple prepend(SimAtom atom)
          Prepend the given atom to the front of this tuple, then return the resulting new Tuple.
 SimTuple product(SimTuple that)
          Return the product of this tuple and that tuple.
 SimTuple replace(int i, SimAtom newAtom)
          Replace the i-th atom, and return the resulting SimTuple.
 SimTuple replace(java.util.Map<SimAtom,SimAtom> map)
          Replace each atom using the given SimAtom->SimAtom map; any atom not in the map will stay unchanged.
 SimAtom tail()
          Returns the last atom of this tuple.
 SimTuple tail(int n)
          Returns the subtuple containing the last n atoms (n must be between 1 and arity)
 java.lang.String toString()
          
 void toString(java.lang.StringBuilder sb)
          Write a human-readable representation of this tuple into the given StringBuilder object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

make

public static SimTuple make(java.util.List<SimAtom> list)
Construct the n-ary tuple; throws an exception if the given list is empty.


make

public static SimTuple make(SimAtom a,
                            SimAtom b)
Construct the binary tuple (a,b)


make

public static SimTuple make(SimAtom atom)
Construct the unary tuple containing the given atom.


make

public static SimTuple make(java.lang.String atom)
Construct the unary tuple containing the given atom.


make

public static SimTuple make(java.lang.String[] atoms)
Construct the tuple containing the given list of atoms; the list must not be empty.


arity

public int arity()
Returns the arity of this tuple.


get

public SimAtom get(int i)
Return the i-th atom from this tuple.


has

public boolean has(SimAtom atom)
Returns true if this tuple contains at least one occurrence of the given atom.


replace

public SimTuple replace(int i,
                        SimAtom newAtom)
Replace the i-th atom, and return the resulting SimTuple.


replace

public SimTuple replace(java.util.Map<SimAtom,SimAtom> map)
Replace each atom using the given SimAtom->SimAtom map; any atom not in the map will stay unchanged.


prepend

public SimTuple prepend(SimAtom atom)
Prepend the given atom to the front of this tuple, then return the resulting new Tuple.


append

public SimTuple append(SimAtom atom)
Append the given atom to the back of this tuple, then return the resulting new Tuple.


product

public SimTuple product(SimTuple that)
Return the product of this tuple and that tuple.


join

public SimTuple join(SimTuple that)
Return the relational join of this tuple and that tuple; throws an exception if the join point doesn't match or if both sides are unary.


hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object that)

Overrides:
equals in class java.lang.Object

head

public SimAtom head()
Returns the first atom of this tuple.


tail

public SimAtom tail()
Returns the last atom of this tuple.


head

public SimTuple head(int n)
Returns the subtuple containing the first n atoms (n must be between 1 and arity)


tail

public SimTuple tail(int n)
Returns the subtuple containing the last n atoms (n must be between 1 and arity)


toString

public void toString(java.lang.StringBuilder sb)
Write a human-readable representation of this tuple into the given StringBuilder object.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

iterator

public java.util.Iterator<SimAtom> iterator()

Specified by:
iterator in interface java.lang.Iterable<SimAtom>