Struct ListPlusOneWrapper<T>
An efficient wrapper for a list plus one element.
public struct ListPlusOneWrapper<T> : IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
Type of items in the collection.
- Implements
-
IEnumerable<T>
- Inherited Members
Constructors
ListPlusOneWrapper(IReadOnlyList<T>, T)
Create a new wrapper for a list plus one element.
public ListPlusOneWrapper(IReadOnlyList<T> list, T plusOne)
Parameters
list
IReadOnlyList<T>List to be wrapped.
plusOne
TExtra element to apparently add to the list.
Properties
Count
Number of items in the list (equal to the number of items in the wrapped list plus one).
public readonly int Count { get; }
Property Value
this[int]
Gets the element at the specified index.
public T this[int index] { get; }
Parameters
index
intThe zero-based index of the element to get.
Property Value
- T
The element at the specified index.
Methods
GetEnumerator()
Returns an enumerator that iterates through the wrapped list plus the additional element.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator that can be used to iterate through the list plus the additional element.