|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object finiteAutomata.IntSet
public class IntSet
Finite set of integers, used to represent sets of states in finite
automata. The elements of each IntSet are maintained in ascending order.
Data Fields: The set of integers is stored in a sorted Vector
of Integers.
IntSet has two special methods to support conversion from NFA to DFA,
based on binary arithmetic.
1. intValue() returns a uniquely-determined integer corresponding
to this IntSet (assuming all elements are >= 0).
Example: intValue of [1,3,4] = 2^1 + 2^3 + 2^4 = 33.
2. setValue(int n) takes a non-negative integer n and
returns a uniquely-determined Intset corresponding
to n.
Example: setValue of 17 is [0,4] because 17 = 2^0 + 2^4.
Field Summary | |
---|---|
protected java.util.Vector |
data
stores the int values as Integers |
Constructor Summary | |
---|---|
IntSet()
0-parameter constructor. |
|
IntSet(int n)
1-parameter constructor. |
|
IntSet(IntSet current)
Copy constructor. |
Method Summary | |
---|---|
void |
add(int n)
Adds a given integer to this IntSet. |
protected void |
addDialog()
Adds a user-specified integer to this IntSet. |
boolean |
contains(int n)
Returns true if a given integer is in this IntSet. |
int |
elementAt(int i)
Returns the int value of the ith element of this IntSet. |
boolean |
equals(java.lang.Object other)
Returns true if other has exactly the same elements as this IntSet. |
int |
indexOf(int n)
Returns index (position) of a given integer in this IntSet. |
int |
intValue()
Returns a unique non-negative integer (bijection from finite subsets of W to W) determined by this set of non-negative integers. |
protected void |
intValueDialog()
Prints the intValue of this IntSet. |
boolean |
isEmpty()
Returns true if this IntSet is empty. |
static void |
main(java.lang.String[] args)
|
int |
max()
Returns the maximum element. |
protected void |
menuHandler(int choice)
Handles user's menu choice. |
int |
min()
Returns the minimum element. |
protected int |
queryChoice()
Reads and returns user's menu choice. |
void |
remove(int n)
Removes a given integer from this IntSet. |
protected void |
removeDialog()
Removes a user-specified integer from this IntSet. |
protected void |
runMenu()
Repeatedly queries user for desired action & responds. |
static IntSet |
setValue(int i)
Calculates a unique IntSet of non-negative integers corresponding a given integer i >= 0 (bijection from W to finite subsets of W). |
protected void |
setValueDialog()
Asks user for an integer >=0 and prints its setValue. |
int |
size()
Returns number of elements in this IntSet. |
boolean |
subsetOf(IntSet other)
Returns true if "this" is a subset of "other". |
java.lang.String |
toString()
Returns a String representation of this IntSet using square brackets and commas. |
IntSet |
union(IntSet other)
Adds all the elements of "other" to this IntSet, forming the union. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Vector data
Constructor Detail |
---|
public IntSet()
public IntSet(int n)
n
- the element to be included in this IntSetpublic IntSet(IntSet current)
current
- the Intset to be copiedMethod Detail |
---|
public int elementAt(int i)
i
- index
public int size()
public boolean isEmpty()
public int min()
public int max()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean contains(int n)
n
- integer to be searched for
public int indexOf(int n)
n
- integer to be searched for
public void add(int n)
n
- integer to be addedpublic void remove(int n)
n
- integer to be removedpublic IntSet union(IntSet other)
other
- set to be unioned with this IntSet
public boolean subsetOf(IntSet other)
other
- the potential superset
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- the IntSet with which this will be compared
public int intValue()
public static IntSet setValue(int i)
i
- the integer to be converted to an IntSet
protected void runMenu()
protected int queryChoice()
protected void menuHandler(int choice)
choice
- choice code to be acted onprotected void addDialog()
protected void removeDialog()
protected void intValueDialog()
protected void setValueDialog()
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |