예제 #1
0
        public static bool Inspect(
            int[] inArray,
            int inStart,
            out int outEnd,
            SegmentResidency inSegmentResidency)
        {
            bool canInspect = false;

            outEnd = inStart + 1;

            if (outEnd < inArray.Length)
            {
                if (inArray[inStart] == inArray[outEnd])
                {
                    while (outEnd < inArray.Length - 1)
                    {
                        outEnd++;
                    }
                }

                inSegmentResidency.Start = inStart;
                inSegmentResidency.End   = outEnd;
                inSegmentResidency.Dist  = inArray[outEnd] - inArray[inStart];
                canInspect = true;
            }

            return(canInspect);
        }
예제 #2
0
 public void Assign(
     SegmentResidency inResidency)
 {
     Start = inResidency.Start;
     End   = inResidency.End;
     Dist  = inResidency.Dist;
 }
예제 #3
0
        public bool Recruit(
            ref int index)
        {
            int theStartIndex = index;

            var canInspect = SegmentResidency.Inspect(_mArray, theStartIndex, out var theEndIndex, _transientResidency);

            if (canInspect)
            {
                int theComparisonResult = _transientResidency.Dist - _minimalResidency.Dist;
                if (theComparisonResult < 0)
                {
                    // Handle subMinimal here:
                    //  We put the previous minimal candidate AND its duplicate_count
                    //  into the subminimal array
                    _subMinimalResidency.Assign(_minimalResidency);
                    _subMinimalResidency.DupCount = _minimalResidency.DupCount;

                    _minimalResidency.Assign(_transientResidency);
                    _minimalResidency.DupCount = 0; // Since we've a new candidate, so reset the dup count
                }
                else if (theComparisonResult == 0)
                {
                    // WTF! so we need to mark this equality situation. trigger a variable to show
                    //  the possible equal values
                    _minimalResidency.DupCount++;
                    // At the end of recruiting process, if this trigger was still set; then
                    //  we need to collect these segments...
                    // Look at FinalizeRecruit below
                }
                else
                {
                    // The inspected segment is greater than the current minimal,
                    //  so check the subminiaml and if it is less than subminimal then
                    //  record it as the current subminimal
                    theComparisonResult = _transientResidency.Dist - _subMinimalResidency.Dist;
                    if (theComparisonResult < 0)
                    {
                        _subMinimalResidency.Assign(_transientResidency);
                        _subMinimalResidency.DupCount = 0;
                    }
                    else if (theComparisonResult == 0)
                    {
                        _subMinimalResidency.DupCount++;
                    }
                }

                index += theEndIndex - theStartIndex;
            }
            else
            {
                index++;
            }
            return(canInspect);
        }
예제 #4
0
        public CSegmentSquad(
            int[] inArray)
        {
            _mArray = inArray;

            _minialSegmentPool     = new CSegmentPool();
            _subMinimalSegmentPool = new CSegmentPool();

            _minimalResidency    = new SegmentResidency();
            _transientResidency  = new SegmentResidency();
            _subMinimalResidency = new SegmentResidency();
        }