Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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;
        }