internal void ComputePages() { List <MapRun> result = new List <MapRun>(); // int cardinality = CharRange.SymCard; int cardinality = Char.MaxValue + 1; int stepSize = PageSize; int current = 0; // Start of the run while (current < cardinality) { int start, finish; int limit = current + stepSize - 1; MapRun thisRun; tMap.GetEnclosingRange(current, out start, out finish); if (finish > limit) { finish = limit; } thisRun = new MapRun(current, finish, tMap[current]); result.Add(thisRun); current = finish + 1; while (current <= limit) { tMap.GetEnclosingRange(current, out start, out finish); if (finish > limit) { finish = limit; } thisRun.Merge(current, finish, tMap[current]); current = finish + 1; } } this.pages = result; }
/// <summary> /// Compares two map runs, but only for the cheap case /// of maps which are NOT mixed values. /// </summary> /// <param name="lRun">The LHS run</param> /// <param name="rRun">The RHS run</param> /// <returns>True if equal</returns> internal bool EqualMaps(MapRun lRun, MapRun rRun) { return (lRun.tag != MapRun.TagType.mixedValues && rRun.tag != MapRun.TagType.mixedValues && tMap[lRun.range.minChr] == tMap[rRun.range.minChr] && tMap[lRun.range.maxChr] == tMap[rRun.range.maxChr]); }
internal void FindMapRuns() { List <MapRun> result = new List <MapRun>(); int cardinality = CharRange.SymCard; int start = 0; // Start of the run int finish = 0; // Get first element and add to List tMap.GetEnclosingRange(start, out start, out finish); result.Add(new MapRun(start, finish)); start = finish + 1; // Now get all the rest ... while (start < cardinality) { tMap.GetEnclosingRange(start, out start, out finish); MapRun lastRun = result[result.Count - 1]; int length = finish - start + 1; if (length >= Partition.CutOff || lastRun.tag == MapRun.TagType.longRun) { result.Add(new MapRun(start, finish)); } else { lastRun.Merge(start, finish); } start = finish + 1; } int total = 0; foreach (MapRun run in result) { if (run.tag == MapRun.TagType.mixedValues) { total += run.Length; } if (run.range.maxChr <= Char.MaxValue) // ==> run is BMP { runsInBMP.Add(run); } else if (run.range.minChr > Char.MaxValue) // ==> not in BMP { runsInNonBMPs.Add(run); } else { MapRun lowPart = new MapRun(run.range.minChr, Char.MaxValue); MapRun highPart = new MapRun(Char.MaxValue + 1, run.range.maxChr); if (run.range.minChr != Char.MaxValue) { lowPart.tag = run.tag; } if (Char.MaxValue + 1 != run.range.maxChr) { highPart.tag = run.tag; } runsInBMP.Add(lowPart); runsInNonBMPs.Add(highPart); } } this.mapRuns = result; }