private static Rch fit(Rch first, Rch second) //AttGeTr: tricky: this function always returns the first reach but when one of both is fitted it returns a fitted copy of the first reach { if ((first.fitted) || (!second.fitted)) { return(first); } Rch ret = first.upto(first.len); ret.fitted = true; return(ret); }
protected Rch(Rch first, Rch second) //this special constructor is used to create a non-standard Reach with 1 compact Reach item <> this in Block List, used intemediately during operator+ { //MethWatch mw = new MethWatch("RchFdn.Rch_first_second"); bl = new Pile <Rch>(); bl.Add(first.bl); bl.Add(second.bl); //bl = pieces(); upd(); fitted = (first.fitted || second.fitted); //mw._void(); }
private Rch badImpl(Rch r) { // AttGeTr: sometimes resulting Reaches are "fitted" - I must research why it is. // the concept of "fitted Reaches" and "not fitted Reaches" SURELY MAKES A LOT OF SENSE // I remember that a resulting reach is "fitted" in case you calculate Reach("abc").from(17) - this gives a fitted empty Reach // "fitted" has the meaning similar to: "a recent calculation violated bounds and the Result had to be fitted to its bounds" ... // IMPORTANT: the badImpl() function is NOT menat for debuggig/investiation of the "fitted" feature !!! // IMPORTANT: some calculations in the Rch Class call badImpl() because of invalid implemention. // the implemention WAS VALID BEFORE the string parameter token has been altered to string... tokens // a valid implementation MUST be found and so you should debug with a breakpoint at the next line: return(r); //place your debuggin breakpoint here! }
internal void cloneFrom(Rch other) //only allowed if the other dies right after this call, example a.cloneFrom(b - c) { bl = other.bl; if (bl.Len == 1) { bl[1] = this; } mBuf = other.mBuf; sLbl = other.sLbl; eLbl = other.eLbl; inf = other.inf; fitted = other.fitted; }
internal Rch(Rch source, Restrict rt) { //MethWatch mw = new MethWatch("RchFdn.Rch_Rch_Restrict"); fitted = rt.fitted | source.fitted; bl = new Pile <Rch>("", true, this); int sbl = 0; int ebl = 0; int sblPos = 0; int eblPos = 0; source.block4Pos(rt.sPos, rt.ePos, ref sbl, ref ebl, ref sblPos, ref eblPos); if (rt.ePos < rt.sPos) { ebl = sbl; eblPos = sblPos - 1; } if ((rt.sWide) && (sblPos <= 1)) { for (int i = sbl - 1; i > 0; i--) { if (source.bl_Len(i) > 0) { break; } sbl = i; sblPos = 1; } } if ((rt.eWide) && (eblPos >= source.bl_Len(ebl))) { for (int i = ebl + 1; i <= source.bl.Len; i++) { if (source.bl_Len(i) > 0) { break; } ebl = i; eblPos = 0; } } if (sbl == ebl) { mBuf = source.bl[sbl].mBuf; //long sInx = mBuf.sIndex(source.bl[sbl].sLbl); // UNBELIEVABLE!!!! This variation slows doen by 10% !!!!! long sInx = source.bl_sInx(sbl); long sInx = source.bl_sInx(sbl); sLbl = "" + mBuf.sLabel((int)(sInx - 1 + sblPos)); eLbl = "" + mBuf.eLabel((int)(sInx - 1 + eblPos)); mBuf.subscribe(this); } else { bl = source.bl.slice(sbl, ebl); bl[1] = source.bl[sbl].from(sblPos); bl[-1] = source.bl[ebl].upto(eblPos); } upd(); //inf = new long[bl.Count + 1, 3]; //mw._void(); }
public static Rch operator-(Rch first, Rch second) { if (first.len * second.len == 0) { return(fit(first, second)); } if ((!first.compact) || (!second.compact)) { if (first.compact) { Rch ret = first; foreach (Rch s in second.bl) { ret = ret - s; } return(ret); } else { Rch ret = fit(first.upto(0) + first.from(first.len + 1), second); // delFromLeftToRight strategy: Rch ret = fit(first.from(first.len + 1), second); foreach (Rch f in first.bl) { Rch diff = f - second; if (diff.len > 0) { if (ret.len == 0) { ret = diff; } else { ret = ret + diff; } } } return(ret); } } if (first.mBuf != second.mBuf) { return(fit(first, second)); } int sInx1 = first.sbdry(first.sLbl); int eInx1 = first.ebdry(first.eLbl) - 1; int sInx2 = second.sbdry(second.sLbl); int eInx2 = second.ebdry(second.eLbl) - 1; if ((eInx2 < sInx1) || (sInx2 > eInx1)) { return(fit(first, second)); } if ((sInx2 <= sInx1) && (eInx2 >= eInx1)) { return(fit(first.upto(0) + first.from(first.len + 1), second)); // delFromLeftToRight strategy: fit(first.from(first.len + 1), second); } if ((sInx2 > sInx1) && (eInx2 < eInx1)) { return(fit(first.upto(sInx2 - sInx1) + first.from(first.len + 1 - (eInx1 - eInx2)), second)); } if (sInx2 <= sInx1) { return(fit(first.from(first.len + 1 - (eInx1 - eInx2)), second)); } return(fit(first.upto(sInx2 - sInx1), second)); }
internal Rch cloneDiff(Rch other, Rch skip) { cloneFrom(this - other - skip); return(other); }
internal Rch cloneDiff(Rch other) { cloneFrom(this - other); return(other); }
private Rch fit(Rch r) { r.fitted = true; return(r); }
public Rch _Rch(Rch v) { stop(); return(v); }