Class SegmentRange
Represents the range of a segment, indicated by two specified positions. The segment positions are inclusive ("into" semantics).
Inheritance
Inherited Members
Namespace: Sdl.LanguagePlatform.Core
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
public class SegmentRange
Constructors
SegmentRange()
Initializes a new instance with default values.
Declaration
public SegmentRange()
SegmentRange(SegmentPosition, SegmentPosition)
Initializes a new instance with the provided positions. No checks are performed to verify that the start position precedes the end position.
Declaration
public SegmentRange(SegmentPosition from, SegmentPosition into)
Parameters
Type | Name | Description |
---|---|---|
SegmentPosition | from | The start position. |
SegmentPosition | into | The end position. |
SegmentRange(Int32, Int32, Int32)
Initializes a new instance of with the given parameters.
Declaration
public SegmentRange(int run, int from, int into)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | run | The segment element index (run) of the range. |
System.Int32 | from | The start position in the run. |
System.Int32 | into | The end position (inclusive) in the run. |
Properties
From
Gets or sets the start position.
Declaration
public SegmentPosition From { get; set; }
Property Value
Type | Description |
---|---|
SegmentPosition |
Into
Gets or sets the end position.
Declaration
public SegmentPosition Into { get; set; }
Property Value
Type | Description |
---|---|
SegmentPosition |
Length
Gets the length of this range if start and end positions are in the same text run,
and -1
otherwise.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Compare(SegmentRange, SegmentRange)
Compares two segment ranges and returns a value indicating their order.
Declaration
public static int Compare(SegmentRange a, SegmentRange b)
Parameters
Type | Name | Description |
---|---|---|
SegmentRange | a | The first of the two items to compare. |
SegmentRange | b | The second of the two items to compare. |
Returns
Type | Description |
---|---|
System.Int32 | An integer value less than zero if a precedes b, zero if a and b are in the same range, and a value greater than zero if a follows b. Only the start positions are compared. |
Contains(SegmentRange)
Tests whether the other range is entirely included in this range (peripheral positions may be identical).
Declaration
public bool Contains(SegmentRange other)
Parameters
Type | Name | Description |
---|---|---|
SegmentRange | other |
Returns
Type | Description |
---|---|
System.Boolean | true if |
Duplicate()
Creates a new instance that is a deep copy of this instance.
Declaration
public SegmentRange Duplicate()
Returns
Type | Description |
---|---|
SegmentRange | A new instance that is a deep copy of this instance. |
Equals(SegmentRange)
Compares the current range to another segment range.
Declaration
public bool Equals(SegmentRange other)
Parameters
Type | Name | Description |
---|---|---|
SegmentRange | other | The range to compare with. |
Returns
Type | Description |
---|---|
System.Boolean | true if both ranges are identical. |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified object is equal to the current object; otherwise, false. |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
IsInside(SegmentPosition)
Tests whether the segment position p
is inside this range.
Declaration
public bool IsInside(SegmentPosition p)
Parameters
Type | Name | Description |
---|---|---|
SegmentPosition | p | The segment position to test |
Returns
Type | Description |
---|---|
System.Boolean |
|
OverlapsWith(SegmentRange)
Tests whether this segment range overlaps with another range.
Declaration
public bool OverlapsWith(SegmentRange other)
Parameters
Type | Name | Description |
---|---|---|
SegmentRange | other |
Returns
Type | Description |
---|---|
System.Boolean | true if the two ranges overlap, and false otherwise. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representation of the object, for display purposes. |