visidia.rule
Class Star

java.lang.Object
  extended by visidia.rule.Star

public class Star
extends java.lang.Object


Field Summary
protected  java.lang.String centerState
           
protected  RuleVector neighborhood
           
 
Constructor Summary
Star()
          default constructor. default centerState is "UNKNOWN"
Star(int arity)
          create a Star. which Neighbors doors are numbered from 0 to arity -1.
Star(Star s)
          constructor of a star clone of an other.
Star(java.lang.String centerState)
           
Star(java.lang.String centerState, int arity)
          create a Star which Neighbors doors are numbered from 0 to arity -1.
 
Method Summary
 void addNeighbor(Neighbor v)
          add a the Neighbor v to the neighborhood. the Neighbor is added at the end of the vector.
 int arity()
           
 java.lang.String centerState()
           
 java.lang.Object clone()
           
 int contains(Neighbor nei)
          looks in the star for a Neighbor equals to the Neighbor nei.
 boolean contains(Star context)
          warning: this method sets doors of context by those of corresponding elements in the star. so always use a copy of the context while using this method. the sense of equality is defined in the class Neighbor
 int containsLabel(Neighbor nei)
          looks in the star for a Neighbor with the same label of the Neighbor nei. the operation "looking for" is Randomized
 boolean containsLabels(Star star)
           
 Neighbor neighbor(int i)
           
 int neighbourDoor(int i)
           
 RuleVector neighbourhood()
           
 void removeAll()
          remove all elements from neighborhood.
 void removeNeighbour(int i)
          remove from neighborhood the neighbor at position i.
 boolean sameCentState(Star s2)
           
 void setCenterState(java.lang.String state)
           
 void setDoors(Star b)
          sets the door numbers of the star, with the value of door numbers of those at the same position in the star b.
 void setState(int position, Neighbor n)
          sets the Neighbor n at the position i in the neighborhood.
 void setStates(Star b)
          sets states of the star elements (center and neighbors), with the value of states of those at the same position in the star b.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

centerState

protected java.lang.String centerState

neighborhood

protected RuleVector neighborhood
Constructor Detail

Star

public Star()
default constructor. default centerState is "UNKNOWN"


Star

public Star(Star s)
constructor of a star clone of an other.

Parameters:
s - a Star.

Star

public Star(java.lang.String centerState)
Parameters:
centerState - the label of the center.

Star

public Star(java.lang.String centerState,
            int arity)
create a Star which Neighbors doors are numbered from 0 to arity -1.

Parameters:
centerState - the label of the center.
arity - the arity of the star.

Star

public Star(int arity)
create a Star. which Neighbors doors are numbered from 0 to arity -1. center state is "UNKNOWN"

Parameters:
arity - the arity of the star.
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setCenterState

public void setCenterState(java.lang.String state)

centerState

public java.lang.String centerState()
Returns:
the state of the center.

neighbor

public Neighbor neighbor(int i)
Parameters:
i - the position
Returns:
the Neighbor on the position i.

neighbourDoor

public int neighbourDoor(int i)
Parameters:
i - a position.
Returns:
the number of the door of the neighbor on the position i.

addNeighbor

public void addNeighbor(Neighbor v)
add a the Neighbor v to the neighborhood. the Neighbor is added at the end of the vector.

Parameters:
v - a new Neighbor

removeNeighbour

public void removeNeighbour(int i)
remove from neighborhood the neighbor at position i.

Parameters:
i - a position.

removeAll

public void removeAll()
remove all elements from neighborhood.


setState

public void setState(int position,
                     Neighbor n)
sets the Neighbor n at the position i in the neighborhood.

Parameters:
position - a position in neighborhood.
n - a Neighbor.

sameCentState

public boolean sameCentState(Star s2)
Parameters:
s2 - star
Returns:
true if centers are equals, false otherwise.

arity

public int arity()
Returns:
the arity of the star.

neighbourhood

public RuleVector neighbourhood()
Returns:
the neighborhood.

setDoors

public void setDoors(Star b)
sets the door numbers of the star, with the value of door numbers of those at the same position in the star b.

Parameters:
b - a star with the same arity.

setStates

public void setStates(Star b)
sets states of the star elements (center and neighbors), with the value of states of those at the same position in the star b.

Parameters:
b - a star with the same arity.

contains

public int contains(Neighbor nei)
looks in the star for a Neighbor equals to the Neighbor nei. ATT!!! it also sets the door number of nei with the door number of the element if found! * the operation looking for is Randomized

Parameters:
nei -
Returns:
the index of the element if found. -1 otherwise.

containsLabel

public int containsLabel(Neighbor nei)
looks in the star for a Neighbor with the same label of the Neighbor nei. the operation "looking for" is Randomized

Parameters:
nei -
Returns:
the index of the element if found. -1 otherwise.

contains

public boolean contains(Star context)
warning: this method sets doors of context by those of corresponding elements in the star. so always use a copy of the context while using this method. the sense of equality is defined in the class Neighbor

Parameters:
context - a context
Returns:
true it's to identify the context with a part of the Star.

containsLabels

public boolean containsLabels(Star star)
Parameters:
star - a star
Returns:
true it's to identify the context with a part of the Star. the identification concerns only labels.

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object