Package org.nineml.coffeegrinder.trees
Class TreeNumber
- java.lang.Object
-
- org.nineml.coffeegrinder.trees.TreeNumber
-
public class TreeNumber extends java.lang.ObjectA numbering of potential trees.This object is used to keep track of what sequential parses have yet to be discovered.
-
-
Field Summary
Fields Modifier and Type Field Description intlengthThe length of the number.
-
Constructor Summary
Constructors Constructor Description TreeNumber()Create a tree number.TreeNumber(TreeNumber seed, int base)Create a tree number with the initial seed and base.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvance()Advance to the next number.intdigit(int pos)Returns the digit at the specified position.booleanhasDigits(java.lang.Integer... check)Check if the number has the specified digitsbooleanisMax()Have we reached the maximum value for this number?java.lang.StringtoString()
-
-
-
Constructor Detail
-
TreeNumber
public TreeNumber()
Create a tree number.
-
TreeNumber
public TreeNumber(TreeNumber seed, int base)
Create a tree number with the initial seed and base.- Parameters:
seed- the seed.base- the base.
-
-
Method Detail
-
isMax
public boolean isMax()
Have we reached the maximum value for this number?- Returns:
- true if we have.
-
advance
public void advance()
Advance to the next number.- Throws:
java.lang.IllegalStateException- if the maximum value has been reached.
-
digit
public int digit(int pos)
Returns the digit at the specified position.- Parameters:
pos- the position.- Returns:
- the digit
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if the position is out of range.
-
hasDigits
public boolean hasDigits(java.lang.Integer... check)
Check if the number has the specified digits- Parameters:
check- the digits.- Returns:
- true if it does.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-