Show / Hide Table of Contents

Struct ListSegment<T>

Delimits a section of a list.

Implements
IList<T>
ICollection<T>
IReadOnlyList<T>
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable
Inherited Members
ValueType.Equals(object)
ValueType.GetHashCode()
ValueType.ToString()
object.GetType()
object.Equals(object, object)
object.ReferenceEquals(object, object)
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

View Source

ListSegment(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

View Source

Count

Gets the number of elements in the segment.

Declaration
public int Count { get; }
Property Value
Type Description
int
View Source

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

index is less than zero; or greater than or equal to Count.

Methods

View Source

Contains(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

true if item is found in this section; otherwise, false.

View Source

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 array at which copying begins.

View Source

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.

View Source

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 item in this section; otherwise, -1.

View Source

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.

Implements

IList<T>
ICollection<T>
IReadOnlyList<T>
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
Collection.AddAll<T>(ICollection<T>, IEnumerable<T>)
Collection.Append<T>(IEnumerable<T>, params T[])
Collection.Copy<T>(IEnumerable<T>, int, MemoryAllocator<T>?)
Collection.FirstOrNone<T>(IEnumerable<T>)
Collection.ForEachAsync<T>(IEnumerable<T>, Func<T, CancellationToken, ValueTask>, CancellationToken)
Collection.ForEach<T>(IEnumerable<T>, Action<T>)
Collection.LastOrNone<T>(IEnumerable<T>)
Collection.Prepend<T>(IEnumerable<T>, params T[])
Collection.SequenceHashCode<T>(IEnumerable<T>, bool)
Collection.ToAsyncEnumerable<T>(IEnumerable<T>, bool)
Collection.ToString<T>(IEnumerable<T>, string, string)
List.InsertOrdered<T>(IList<T>, T, delegate*<T?, T?, int>)
List.InsertOrdered<T>(IList<T>, T, Comparison<T?>)
List.InsertOrdered<T, TComparer>(IList<T>, T, TComparer)
List.Insert<T>(IList<T>, Index, T)
List.RemoveAt<T>(IList<T>, Index)
List.Slice<T>(IList<T>, Range)
List.ToArray<TInput, TOutput>(IList<TInput>, delegate*<TInput, TOutput>)
List.ToArray<TInput, TOutput>(IList<TInput>, delegate*<TInput, TOutput>)
List.ToArray<TInput, TOutput>(IList<TInput>, Converter<TInput, TOutput>)
List.ToArray<TInput, TOutput>(IList<TInput>, Func<int, TInput, TOutput>)
Collection.Convert<T, TOutput>(IReadOnlyCollection<T>, Func<T, TOutput>)
List.Convert<TInput, TOutput>(IReadOnlyList<TInput>, Func<TInput, TOutput>)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾