|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--org.pealfactory.ring.PN
Represents a set of place notation, parsed from a String which may be
in any recognised format. The place notation is held in an internal format
in which each change is represented by a byte array - see getChange(int).
These byte arrays are suitable for application to Row objects using the call
Row.applyPN(byte[]). Symmetric notations are expanded during parsing, so one
place notation change is available for every row of a method's lead.
For information about the notation formats supported by this class, see the
javadoc for the (private) parse() method. For the bell place characters
expected on higher numbers, see Constants.kROUNDS.
Various properties of the place notation are available for query once the PN object has been constructed, including whether the notation is symmetric, whether it is right-place, and the stage (highest bell number) it applies to. The latter property is "guessed" by the parser and may not be accurate for notation formats in which final external places are not given.
Some attention to performance issues has been paid in the design of this class, but if performance is critical direct use of place notation permutations should be avoided.
| Field Summary | |
private boolean |
fContainsCross
True if PN contains cross notation - used for guessing number of bells |
private int |
fHighestPlace
The highest place made in the PN, used for guessing number of bells (0 = lead) |
private int |
fHighestPlaceNotHalfLead
The highest place made in the PN not at the half-lead, used for guessing number of bells (0 = lead) |
private java.lang.String |
fOriginalString
|
private byte[][] |
fPN
Contains a byte[] for each change in original PN |
private static byte[] |
kCROSSCHANGE
Cross change X represented as a 0-length array |
| Fields inherited from interface org.pealfactory.ring.Constants |
kCALL_BOB, kCALL_EXTREME, kCALL_PLAIN, kCALL_SINGLE, kCALL_USER, kCHAR_CROSS, kCHAR_LH, kMAXNBELLS, kMINNBELLS, kROUNDS |
| Constructor Summary | |
PN(java.lang.String pn)
|
|
| Method Summary | |
private boolean |
changesEqual(byte[] pn1,
byte[] pn2)
Returns true if two place notation changes are equal - note that the final place is important, so if one change specifies "n" and the other doesn't, they won't match. |
byte[] |
getChange(int i)
Gets the place notation for a particular change. |
int |
getLength()
|
int |
guessNBells()
Tries to work out the stage of the method represented by the place notation. |
int |
highestPlace()
Returns the highest place made in the pn. |
boolean |
isRightPlace()
A right-place method has an even-length lead, and every even change is a cross. |
boolean |
isRotationallySymmetric(int nbells)
Returns true if the place notation has double-method symmetry (to see whether it represents a double method, test isSymmetric() as well). |
boolean |
isSymmetric()
Returns true if place notation is symmetrical about the halfway point. |
private void |
parse()
Parses place notation String, placing results into internal format array ready for use. |
private int |
reflectSymmetricNotation(int fromHere,
java.util.Vector pn)
Adds reflected notation between fromHere up
to but not including the current PN entry, which is taken as
the pivot point. |
private byte[] |
reverseChange(byte[] pn1,
int nbells)
Swap change front to back, e.g. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private static final byte[] kCROSSCHANGE
private java.lang.String fOriginalString
private byte[][] fPN
private int fHighestPlace
private int fHighestPlaceNotHalfLead
private boolean fContainsCross
| Constructor Detail |
public PN(java.lang.String pn)
| Method Detail |
public java.lang.String toString()
toString in class java.lang.Objectpublic int getLength()
public byte[] getChange(int i)
public int guessNBells()
public int highestPlace()
public boolean isRightPlace()
public boolean isSymmetric()
public boolean isRotationallySymmetric(int nbells)
private boolean changesEqual(byte[] pn1,
byte[] pn2)
private byte[] reverseChange(byte[] pn1,
int nbells)
private void parse()
private int reflectSymmetricNotation(int fromHere,
java.util.Vector pn)
fromHere up
to but not including the current PN entry, which is taken as
the pivot point.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||