Table of Contents

Class IndexSegment

Namespace
Hi.Common
Assembly
HiGeom.dll

Represents a segment of indices with a beginning and ending point. Used for defining ranges of data in collections or arrays.

public class IndexSegment : IEquatable<IndexSegment>, IMakeXmlSource
Inheritance
IndexSegment
Implements
Inherited Members
Extension Methods

Constructors

IndexSegment()

Initializes a new instance of the IndexSegment class.

public IndexSegment()

IndexSegment(IndexSegment)

Initializes a new instance of the IndexSegment class by copying another instance.

public IndexSegment(IndexSegment src)

Parameters

src IndexSegment

The source index segment to copy from.

IndexSegment(int, int)

Initializes a new instance of the IndexSegment class with the specified begin and end indices.

public IndexSegment(int begin, int end)

Parameters

begin int

The beginning index (inclusive).

end int

The ending index (exclusive).

IndexSegment(XElement)

Initializes a new instance of the IndexSegment class from an XML element.

public IndexSegment(XElement src)

Parameters

src XElement

The XML element containing the index segment data.

Fields

XName

The XML element name used for serialization.

public static string XName

Field Value

string

begin

Begin index. Inclusive.

public int begin

Field Value

int

end

End index. Exclusive.

public int end

Field Value

int

Properties

Begin

Gets or sets the beginning index of the segment (inclusive).

public int Begin { get; set; }

Property Value

int

End

Gets or sets the ending index of the segment (exclusive).

public int End { get; set; }

Property Value

int

Length

Gets the length of the segment (End - Begin).

public int Length { get; }

Property Value

int

Methods

Any()

Determines whether this index segment contains any indices.

public bool Any()

Returns

bool

true if the segment contains any indices; otherwise, false.

Contains(int)

Determines whether this index segment contains the specified index.

public bool Contains(int index)

Parameters

index int

The index to check.

Returns

bool

true if the index is within the segment; otherwise, false.

Enumerate()

Enumerates all indices within this segment.

public IEnumerable<int> Enumerate()

Returns

IEnumerable<int>

An enumerable collection of all indices within the segment.

Equals(IndexSegment)

Determines whether the specified index segment is equal to the current index segment.

public bool Equals(IndexSegment other)

Parameters

other IndexSegment

The index segment to compare with the current index segment.

Returns

bool

true if the specified index segment is equal to the current index segment; otherwise, false.

Equals(object)

Determines whether the specified object is equal to the current index segment.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current index segment.

Returns

bool

true if the specified object is equal to the current index segment; otherwise, false.

Expand(int)

Expands this index segment to include the specified value if needed.

public void Expand(int v)

Parameters

v int

The value to include in the segment.

GetHashCode()

Returns a hash code for this index segment.

public override int GetHashCode()

Returns

int

A hash code for the current index segment.

GetIndexSegment<TData>(IList<TData>, int, int, Func<TData, int?>)

Gets an index segment from a list of data items based on the specified indices.

public static IndexSegment GetIndexSegment<TData>(IList<TData> steps, int cacheStepIndex, int keyStepIndex, Func<TData, int?> dataToKeyIndexFunc)

Parameters

steps IList<TData>

The list of data items.

cacheStepIndex int

The cache step index.

keyStepIndex int

The key step index.

dataToKeyIndexFunc Func<TData, int?>

A function that extracts an index from a data item.

Returns

IndexSegment

An index segment representing the range of indices.

Type Parameters

TData

The type of data items.

MakeXmlSource(string, string)

Creates an XML element representing this index segment.

public XElement MakeXmlSource(string baseDirectory, string relFile)

Parameters

baseDirectory string

The base directory for relative paths.

relFile string

The relative file path.

Returns

XElement

An XML element representing this index segment.

ToString()

Returns a string representation of this index segment.

public override string ToString()

Returns

string

A string representation of the current index segment.