Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Properties | Public Member Functions | List of all members
Loyc.Syntax.IndexRange Struct Reference

A mutable pair of (StartIndex, Length) that implements IIndexRange. More...


Source file:
Inheritance diagram for Loyc.Syntax.IndexRange:
Loyc.Syntax.IIndexRange

Remarks

A mutable pair of (StartIndex, Length) that implements IIndexRange.

Properties

int StartIndex [get, set]
 
int Length [get, set]
 
int EndIndex [get, set]
 
- Properties inherited from Loyc.Syntax.IIndexRange
int StartIndex [get]
 
int EndIndex [get]
 
int Length [get]
 

Public Member Functions

 IndexRange (int startIndex, int length=0)
 
IndexRange Normalize ()
 Ensures that StartIndex <= EndIndex by swapping the two if the Length is negative. More...
 
IndexRange GetRangeOfOverlap (IndexRange other)
 Assuming both ranges are normalized, returns the range of overlap between them. If the ranges do not overlap, the Length of the returned range will be zero or negative. More...
 
bool Overlaps (IndexRange other)
 Returns true if, assuming both ranges are normalized, the two regions share at least one common character. More...
 
bool Contains (IndexRange other)
 Returns true if, assuming both ranges are normalized, the other range is entirely within the boundaries of this range. More...
 

Member Function Documentation

bool Loyc.Syntax.IndexRange.Contains ( IndexRange  other)

Returns true if, assuming both ranges are normalized, the other range is entirely within the boundaries of this range.

IndexRange Loyc.Syntax.IndexRange.GetRangeOfOverlap ( IndexRange  other)

Assuming both ranges are normalized, returns the range of overlap between them. If the ranges do not overlap, the Length of the returned range will be zero or negative.

IndexRange Loyc.Syntax.IndexRange.Normalize ( )
inline

Ensures that StartIndex <= EndIndex by swapping the two if the Length is negative.

Exceptions
OverflowExceptionAn integer overflow occurred.
Returns
this.
bool Loyc.Syntax.IndexRange.Overlaps ( IndexRange  other)

Returns true if, assuming both ranges are normalized, the two regions share at least one common character.

Note: this returns false if either of the ranges has a Length of zero and is at the boundary of the other range.