org.pealfactory.compose.halfleadspliced
Class Method

java.lang.Object
  extended by org.pealfactory.compose.halfleadspliced.Method

 class Method
extends java.lang.Object

Represents a method: holds name, abbreviation, place notation and leadhead, as well as internal data used to increase performance, such as table permutation numbers for leadhead and place notation permutations. Methods are provided to calculate these perm numbers, and to use them to generate and count music in a lead of the method from a giving starting row.

Since Indis, an alternate constructor is available which supports "composite" methods. These contain the first-half place notation for one method (e.g. Cambridge) and the second half of another (e.g. Yorkshire). Such methods are automatically assigned a two-letter abbreviation (e.g. "CY"). It is no longer possible to generate or count music for individual half-leads.

Much of the code within this class has been heavily tuned for performance, and should not be modified without extensive benchmarking on a range of searches.


Field Summary
private  int f1stHalfLength
           
private  int f2ndHalfLength
           
private  java.lang.String fAbbrev
           
private  ImmutableRow[] fCallPerms
           
private  int fCOM
          =1 if two halves of composite are different methods
private  ImmutableRow fHalflead
           
private  int fIndex1
           
private  int fIndex2
           
private  ImmutableRow fLeadhead
           
private  int fLeadLength
           
private  int[] fLeadPermNums
           
private  int fMethodIndex
           
private  java.lang.String fName
           
private  PN fPN
           
private  PN fPN2
           
private  int[] fPNPermNums
           
static byte[] kBOB_PN
           
static int kNCALLTYPES
           
static byte[] kSINGLE_PN
           
 
Constructor Summary
Method(Method m1, Method m2, int index)
          Create composite method with first half pn from m1 and second half from m2.
Method(java.lang.String name, java.lang.String pn)
           
Method(java.lang.String name, java.lang.String abbrev, java.lang.String pn)
          Note calcPerms() and updateLeadPerms() MUST be called prior to use.
 
Method Summary
 void calcPerms(Tables tables)
          Calculates place notation, and leadhead permutations for this method.
 boolean equals(java.lang.Object o)
          Two methods are equal if their names are equal
 void generateLead(RowNode start, int[] rowNums)
          Generates node numbers for entire lead of method, from leadhead up to leadend.
 java.lang.String getAbbrev()
           
 int getCOM()
          Returns 0 if this method has the same 1st & 2nd halves, or 1 if it is a composite made out of two different halfleads.
 ImmutableRow getHalflead()
          Final for speed.
 int getIndex1()
           
 int getIndex2()
           
 ImmutableRow getLeadhead()
          Final for speed.
 int getLeadLength()
          Final for speed
 int getLeadPermNum(int call)
          Final for speed (inlining)
 int getMethodIndex()
          Final for speed
 java.lang.String getName()
           
 PN getPN()
           
private  void init(java.lang.String name, java.lang.String abbrev, PN pn1, PN pn2)
           
 int leadMusic(RowNode start)
          Calculates music score for one lead of method, from leadhead up to but NOT INCLUDING following leadhead.
 int nRowsInFirstHalf()
           
 int nRowsInSecondHalf()
           
 void setMethodIndex(int methodIndex)
           
 void updateLeadPerms(Tables tables)
          Before use the leadhead perm numbers must be incremented so they correctly point into the node permtables.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kNCALLTYPES

public static final int kNCALLTYPES
See Also:
Constant Field Values

kBOB_PN

public static final byte[] kBOB_PN

kSINGLE_PN

public static final byte[] kSINGLE_PN

fMethodIndex

private int fMethodIndex

fIndex1

private int fIndex1

fIndex2

private int fIndex2

fName

private java.lang.String fName

fAbbrev

private java.lang.String fAbbrev

fPN

private PN fPN

fPN2

private PN fPN2

fPNPermNums

private int[] fPNPermNums

fLeadhead

private ImmutableRow fLeadhead

fHalflead

private ImmutableRow fHalflead

fCallPerms

private ImmutableRow[] fCallPerms

fLeadLength

private int fLeadLength

f1stHalfLength

private int f1stHalfLength

f2ndHalfLength

private int f2ndHalfLength

fLeadPermNums

private int[] fLeadPermNums

fCOM

private int fCOM
=1 if two halves of composite are different methods

Constructor Detail

Method

public Method(java.lang.String name,
              java.lang.String pn)

Method

public Method(java.lang.String name,
              java.lang.String abbrev,
              java.lang.String pn)
Note calcPerms() and updateLeadPerms() MUST be called prior to use. The latter can only be called after all methods have been added.


Method

public Method(Method m1,
              Method m2,
              int index)
Create composite method with first half pn from m1 and second half from m2. Note that the methods indices of m1 and m2 must already have been set up.

Since:
Indis
Method Detail

init

private void init(java.lang.String name,
                  java.lang.String abbrev,
                  PN pn1,
                  PN pn2)

equals

public boolean equals(java.lang.Object o)
Two methods are equal if their names are equal

Overrides:
equals in class java.lang.Object

getName

public java.lang.String getName()

getAbbrev

public java.lang.String getAbbrev()

getPN

public PN getPN()

getMethodIndex

public final int getMethodIndex()
Final for speed


setMethodIndex

public void setMethodIndex(int methodIndex)

getIndex1

public final int getIndex1()

getIndex2

public final int getIndex2()

getLeadLength

public final int getLeadLength()
Final for speed


nRowsInFirstHalf

public int nRowsInFirstHalf()

nRowsInSecondHalf

public int nRowsInSecondHalf()

getCOM

public int getCOM()
Returns 0 if this method has the same 1st & 2nd halves, or 1 if it is a composite made out of two different halfleads.


getLeadPermNum

public final int getLeadPermNum(int call)
Final for speed (inlining)


getLeadhead

public final ImmutableRow getLeadhead()
Final for speed.


getHalflead

public final ImmutableRow getHalflead()
Final for speed.


leadMusic

public final int leadMusic(RowNode start)
Calculates music score for one lead of method, from leadhead up to but NOT INCLUDING following leadhead. Optimised - uses RowNodes


generateLead

public final void generateLead(RowNode start,
                               int[] rowNums)
Generates node numbers for entire lead of method, from leadhead up to leadend. Optimised - uses RowNodes


calcPerms

public void calcPerms(Tables tables)
Calculates place notation, and leadhead permutations for this method. !! VERY IMPORTANT - leadhead perm numbers are at this stage temporary; they must be incremented by the total number of PN perms before use!!

See Also:
updateLeadPerms(org.pealfactory.compose.halfleadspliced.Tables)

updateLeadPerms

public void updateLeadPerms(Tables tables)
Before use the leadhead perm numbers must be incremented so they correctly point into the node permtables. To do this, we increment by the total number of PN perms for all methods