public Vector toShifts;
int fromRatio; // number of steps in fromShifts to one toRatio unit
int toRatio; // number of steps in toShifts to one fromRatio
+
+ /**
+ *
+ * @return series of intervals mapped in from
+ */
+ public int[] getFromRanges()
+ {
+ return getRanges(fromShifts);
+ }
+ public int[] getToRanges()
+ {
+ return getRanges(toShifts);
+ }
+
+ private int[] getRanges(Vector shifts)
+ {
+ int[] rnges = new int[2*shifts.size()];
+ Enumeration e = shifts.elements();
+ int i=0;
+ while (e.hasMoreElements())
+ {
+ int r[] = (int[]) e.nextElement();
+ rnges[i++] = r[0];
+ rnges[i++] = r[1];
+ }
+ return rnges;
+ }
/**
* lowest and highest value in the from Map
*/
* lowest and highest value in the to Map
*/
int[] toRange=null;
+ /**
+ *
+ * @return length of mapped phrase in from
+ */
public int getFromRatio()
{
return fromRatio;
}
+ /**
+ *
+ * @return length of mapped phrase in to
+ */
public int getToRatio()
{
return toRatio;
{
iv[0] = startpos;
}
- while (i!=fe) {
+ while (--i!=fe) { // fix apparent logic bug when fe==-1
ranges.addElement(iv); // add (truncated) reversed interval
- iv = (int[]) fromShifts2.elementAt(--i);
+ iv = (int[]) fromShifts2.elementAt(i);
iv = new int[] { iv[1], iv[0] }; // reverse and clone
}
if (i==fe) {
}*/
System.out.print("Success?\n"); // if we get here - something must be working!
}
+ /**
+ *
+ * @return a MapList whose From range is this maplist's To Range, and vice versa
+ */
+ public MapList getInverse()
+ {
+ return new MapList(getToRanges(), getFromRanges(), getToRatio(), getFromRatio());
+ }
}