private bool _CollectDupSegments( int inDupCount, CSegmentPool inSegmentPool, int inMaxAllowedDup) { bool wasSuccessful = true; if (inDupCount > 0) { if (inDupCount <= inMaxAllowedDup) { int theMinimalDistance = inSegmentPool.GetMinDist(); for (int i = 0, j = 0; i < _mArray.Length - 1 || j < inDupCount; i++) { var theDistance = Math.Abs(_mArray[i + 1]) - Math.Abs(_mArray[i]); if (theDistance == theMinimalDistance && inSegmentPool.GetSegment(0).StartingPoint.Index != i ) // Be careful about the same segment { int theStartIndex = i, theEndIndex = i + 1; CSegment theSegment = CSegment.Create(_mArray, theStartIndex, ref theEndIndex); inSegmentPool.Add(theSegment); j++; } } } else { wasSuccessful = false; } } return(wasSuccessful); }
public bool FinalizeRecruit() { // First create one segment for the minimal residency CSegment theSegment = CSegment.Create(_mArray, _minimalResidency.Start, ref _minimalResidency.End); _minialSegmentPool.Add(theSegment); // Then handle the dups of minimal var wasSuccessful = _CollectDupSegments(_minimalResidency.DupCount, _minialSegmentPool, 5); // Now look at the subMinimal and if there was a valid segment, create and put it into the // subminimal segment array if (_subMinimalResidency.End > _subMinimalResidency.Start) { theSegment = CSegment.Create(_mArray, _subMinimalResidency.Start, ref _subMinimalResidency.End); _subMinimalSegmentPool.Add(theSegment); } if (wasSuccessful) { wasSuccessful = _CollectDupSegments(_subMinimalResidency.DupCount, _subMinimalSegmentPool, 3); } return(wasSuccessful); }