Struct ListSegment<T>
Delimits a section of a list.
Inherited Members
Namespace: DotNext.Collections.Generic
Assembly: DotNext.dll
Syntax
public readonly struct ListSegment<T> : IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T | The type of elements in the section. |
Remarks
This collection is read-only and does not allow the addition or removal of elements. However individual elements of the list can be modified using indexer.
Constructors
| Edit this page View SourceListSegment(IList<T>, Range)
Initializes a new segment of the list.
Declaration
public ListSegment(IList<T> list, Range range)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | The list containing the range of elements to delimit. |
Range | range | The range of elements. |
Properties
| Edit this page View SourceCount
Gets the number of elements in the segment.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
this[int]
Gets or sets element at the specified index.
Declaration
public T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the element in this segment. |
Property Value
Type | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Methods
| Edit this page View SourceContains(T)
Determines whether this section contains a specified value.
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The object to locate in this section. |
Returns
Type | Description |
---|---|
bool |
CopyTo(T[], int)
Copies the elements in this section to an array.
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The destination of the elements copied from this section. |
int | arrayIndex | The zero-based index in |
GetEnumerator()
Gets enumerator of elements in this section.
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> | The enumerator of elements in this section. |
IndexOf(T)
Determines the index of a specific item.
Declaration
public int IndexOf(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The object to locate in this section. |
Returns
Type | Description |
---|---|
int | The index of |
TryGetSpan(out Span<T>)
Attempts to get span over elements in this segment.
Declaration
public bool TryGetSpan(out Span<T> span)
Parameters
Type | Name | Description |
---|---|---|
Span<T> | span | The span over elements in this segment. |
Returns
Type | Description |
---|---|
bool | true if the underlying list supports conversion to span; otherwise false. |