GetPreviousValidSpan() public method

Gets the previous valid span or null if there's none left. This includes the input (position) if it happens to lie within this valid span. This method merges all consecutive valid spans.
public GetPreviousValidSpan ( HexPosition position, HexPosition lowerBounds, bool fullSpan ) : HexSpan?
position HexPosition Start position to check
lowerBounds HexPosition End position
fullSpan bool true if positions after should be included /// in the returned result. This could result in worse performance.
return HexSpan?
示例#1
0
		protected IEnumerable<HexSpan> GetValidSpansReverse(HexBuffer buffer, HexPosition start, HexPosition lowerBounds) {
			var pos = start;
			bool fullSpan = true;
			for (;;) {
				var span = buffer.GetPreviousValidSpan(pos, lowerBounds, fullSpan);
				if (span == null)
					break;

				var newStart = HexPosition.Max(lowerBounds, span.Value.Start);
				var newEnd = HexPosition.Min(pos + 1, span.Value.End);
				if (newStart < newEnd)
					yield return HexSpan.FromBounds(newStart, newEnd);

				if (span.Value.Start == 0)
					break;
				pos = span.Value.Start - 1;
				fullSpan = false;
			}
		}