BorrowedList<TElement> Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A collection that is optimized for adding elements to its end, and accessing them by index. BorrowedList<TElement> uses pooled arrays to store elements, which allows for frequent creation and disposal of new collections without causing GC pressure.
public sealed class BorrowedList<TElement> : IDisposable, System.Collections.Generic.ICollection<TElement>, System.Collections.Generic.IEnumerable<TElement>, System.Collections.Generic.IList<TElement>, System.Collections.Generic.IReadOnlyCollection<TElement>, System.Collections.Generic.IReadOnlyList<TElement>
type BorrowedList<'Element> = class
interface IList<'Element>
interface ICollection<'Element>
interface seq<'Element>
interface IEnumerable
interface IReadOnlyList<'Element>
interface IReadOnlyCollection<'Element>
interface IDisposable
Public NotInheritable Class BorrowedList(Of TElement)
Implements ICollection(Of TElement), IDisposable, IEnumerable(Of TElement), IList(Of TElement), IReadOnlyCollection(Of TElement), IReadOnlyList(Of TElement)
Type Parameters
- TElement
The type of elements in the list.
- Inheritance
-
BorrowedList<TElement>
- Implements
-
ICollection<T> ICollection<TElement> IEnumerable<T> IEnumerable<TElement> IList<TElement> IReadOnlyCollection<T> IReadOnlyCollection<TElement> IReadOnlyList<TElement> IEnumerable IDisposable
Remarks
The BorrowedList<TElement> internal storage is allocated in segments: a BorrowedList<TElement> containing at least one element will rent at least a segment from the pooled array (for a minimal allocation, in the current implementation of 8KB). That memory will be returned to the array pool when the BorrowedList<TElement> is disposed.
Constructors
BorrowedList<TElement>() |
Creates a new instance of BorrowedList<TElement>. |
BorrowedList<TElement>(IEnumerable<TElement>) |
Creates a new instance of BorrowedList<TElement> which contains
the elements from |
BorrowedList<TElement>(Int32) |
Creates a new instance of BorrowedList<TElement> which contains
|
Properties
Count | System.Object.Count |
Item[Int32] | Gets or sets the element at the specified index. |
Methods
Add(TElement) | Adds an item to the ICollection<T>. |
Clear() | Removes all items from the ICollection<T>. |
Contains(TElement) | Determines whether the ICollection<T> contains a specific value. |
CopyTo(IList<TElement>, Int32, Int32, Int32) |
Copies the specified range of the BorrowedList<TElement>
into |
Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
GetEnumerator() | Returns an enumerator that iterates through the collection. |
IndexOf(TElement) |
Returns the first index of |
Insert(Int32, TElement) | Inserts an item to the IList<T> at the specified index. |
Remove(TElement) | Removes the first occurrence of a specific object from the ICollection<T>. |
RemoveAt(Int32) | Removes the IList<T> item at the specified index. |
ReplaceWith(BorrowedList<TElement>) |
Replaces the current content of the BorrowedList<TElement> with the elements
from |
ReplaceWith(IEnumerable<TElement>) |
Replaces the current content of the BorrowedList<TElement> with the elements
from |
Resize(Int32) |
Resizes the BorrowedList<TElement> to contain |
Sort() |
Sort the elements in the BorrowedList<TElement> using the default comparer for
|
Sort(Comparison<TElement>) |
Sort the elements in the BorrowedList<TElement> using |
Sort(IComparer<TElement>) |
Sort the elements in the BorrowedList<TElement> using |
Sort(Int32, Int32, Comparison<TElement>) |
Sort the elements in the BorrowedList<TElement> using |
Sort(Int32, Int32, IComparer<TElement>) |
Sort the elements in the BorrowedList<TElement> using |
Explicit Interface Implementations
ICollection<TElement>.CopyTo(TElement[], Int32) | Copies the elements of the ICollection<T> to an Array, starting at a particular Array index. |
ICollection<TElement>.IsReadOnly | Gets a value indicating whether the ICollection<T> is read-only. |
IEnumerable.GetEnumerator() | Returns an enumerator that iterates through a collection. |
IEnumerable<TElement>.GetEnumerator() | Returns an enumerator that iterates through the collection. |
Extension Methods
EmptyIfNull<T>(IEnumerable<T>) |
Return this enumeration in case it is not null. In case it is null return empty enumeration. |