ILGPU  0.9.0
ILGPU.Util.InlineList< T > Class Template Reference

An inline array list that has to be passed by reference to avoid unnecessary heap allocations. More...

Classes

struct  DefaultFormatter
 The default formatter that calls the object.ToString() method. More...
 
interface  IFormatter
 An abstract value formatter for inline lists. More...
 

Public Member Functions

void Reserve (int capacity)
 Ensures that this list as at least the given capacity. More...
 
void Add (T item)
 Adds the given item to this list. More...
 
void AddRange< TList > (TList list)
 Adds the given items to this list. More...
 
void AddRange (in ReadOnlySpan< T > span)
 Adds the given items to this list. More...
 
void Clear ()
 Clears all items. More...
 
void Resize (int count)
 Resizes the current list to have a sufficient capacity for all items while settings the number of elements to count . More...
 
readonly bool Contains< TComparer > (T item, TComparer comparer)
 Returns true if the given item is contained in this list. More...
 
readonly void CopyTo (T[] array, int arrayIndex)
 Copies the internally stored items to the given array. More...
 
void Insert (T item, int index)
 Inserts the given item at the specified index. More...
 
readonly int IndexOf< TComparer > (T item, TComparer comparer)
 Returns the index of the given item. More...
 
bool Remove< TComparer > (T item, TComparer comparer)
 Removes the given item from the list. More...
 
void RemoveAt (int index)
 Removes the item with the specified index. More...
 
void Reverse ()
 Reverses all items in this list. More...
 
void MoveTo (ref InlineList< T > list)
 Moves the current items to the given target list. More...
 
readonly void CopyTo (ref InlineList< T > list)
 Copies all items to the given target list. More...
 
readonly InlineList< T > Clone ()
 Clones this inline list. More...
 
readonly InlineList< T > Slice (int startIndex, int count)
 Slices a sub inline list out of this one. More...
 
readonly void SliceTo (int startIndex, int count, ref InlineList< T > list)
 Slices a sub inline list out of this one into the given one. More...
 
readonly bool Equals< TComparer > (InlineList< T > other, TComparer comparer)
 Returns true if the given list is equal to the current list. More...
 
readonly Span< T > AsSpan ()
 Converts this inline list into a span. More...
 
readonly ReadOnlySpan< T > AsReadOnlySpan ()
 Converts this inline list into a read-only span. More...
 
readonly ReadOnlySpan< T >.Enumerator GetEnumerator ()
 Returns an enumerator to enumerate all items in this list. More...
 
readonly string ToString< TFormatter > (TFormatter formatter)
 Returns the string representation of this list. More...
 
readonly override string ToString ()
 Returns the string representation of this list. More...
 

Static Public Member Functions

static InlineList< T > Create (int capacity)
 Creates a new inline list with the given capacity and storage capacity. More...
 
static InlineList< T > Create (T item)
 Creates a new inline list with the given item. More...
 
static InlineList< T > Create (T item1, T item2)
 Creates a new inline list with the given items. More...
 
static InlineList< T > Create< TList > (TList list)
 Creates a new inline list from the given list. More...
 
static operator Span< T > (InlineList< T > list)
 Converts the given list into a span. More...
 
static implicit operator ReadOnlySpan< T > (InlineList< T > list)
 Converts the given list into a read-only span. More...
 
static InlineList< T > ToInlineList< T > (this ReadOnlySpan< T > span)
 Creates a new inline list from the given span. More...
 
static void CopyTo< T > (this ReadOnlySpan< T > span, ref InlineList< T > list)
 Copies the items from the given span to the inline list. More...
 
static string ToString< T, TFormatter > (this ReadOnlySpan< T > span, TFormatter formatter)
 Returns the string representation of the given span. More...
 

Public Attributes

readonly int Capacity => items.Length
 The total capacity. More...
 

Static Public Attributes

static readonly InlineList< T > Empty = new InlineList<T>(0)
 An empty inline list. More...
 

Properties

int Count [get]
 Returns the number of items. More...
 
readonly ref T this[int index] [get]
 Returns a reference to the i-th item. More...
 

Detailed Description

An inline array list that has to be passed by reference to avoid unnecessary heap allocations.

Inline list utility methods.

Template Parameters
TThe element type.

Member Function Documentation

void ILGPU.Util.InlineList< T >.Add ( item)

Adds the given item to this list.

Parameters
itemThe item to add.
void ILGPU.Util.InlineList< T >.AddRange ( in ReadOnlySpan< T >  span)

Adds the given items to this list.

Parameters
spanThe source span.
void ILGPU.Util.InlineList< T >.AddRange< TList > ( TList  list)

Adds the given items to this list.

Template Parameters
TListThe list type.
Parameters
listThe source list.
Type Constraints
TList :IReadOnlyList<T> 
readonly ReadOnlySpan<T> ILGPU.Util.InlineList< T >.AsReadOnlySpan ( )

Converts this inline list into a read-only span.

Returns
The read-only span.
readonly Span<T> ILGPU.Util.InlineList< T >.AsSpan ( )

Converts this inline list into a span.

Returns
The span.
void ILGPU.Util.InlineList< T >.Clear ( )

Clears all items.

readonly InlineList<T> ILGPU.Util.InlineList< T >.Clone ( )

Clones this inline list.

Returns
A clone of the current inline list.
readonly bool ILGPU.Util.InlineList< T >.Contains< TComparer > ( item,
TComparer  comparer 
)

Returns true if the given item is contained in this list.

Parameters
itemThe item to look for.
comparerThe comparer to use.
Returns
True, if the given item contained in this list.
Type Constraints
TComparer :IEqualityComparer<T> 
TComparer :IndexOf 
TComparer :item 
TComparer :comparer 
readonly void ILGPU.Util.InlineList< T >.CopyTo ( T[]  array,
int  arrayIndex 
)

Copies the internally stored items to the given array.

Parameters
arrayThe target array to copy to.
arrayIndexThe base index.
readonly void ILGPU.Util.InlineList< T >.CopyTo ( ref InlineList< T >  list)

Copies all items to the given target list.

Parameters
listThe target list.
static void ILGPU.Util.InlineList< T >.CopyTo< T > ( this ReadOnlySpan< T >  span,
ref InlineList< T >  list 
)
static

Copies the items from the given span to the inline list.

Template Parameters
TThe element type.
Parameters
spanThe span instance.
listA reference to the inline list.
static InlineList<T> ILGPU.Util.InlineList< T >.Create ( int  capacity)
static

Creates a new inline list with the given capacity and storage capacity.

Parameters
capacityThe capacity.
Returns
The new inline list.
static InlineList<T> ILGPU.Util.InlineList< T >.Create ( item)
static

Creates a new inline list with the given item.

Parameters
itemThe first item.
Returns
The created inline list.
static InlineList<T> ILGPU.Util.InlineList< T >.Create ( item1,
item2 
)
static

Creates a new inline list with the given items.

Parameters
item1The first item.
item2The second item.
Returns
The created inline list.
static InlineList<T> ILGPU.Util.InlineList< T >.Create< TList > ( TList  list)
static

Creates a new inline list from the given list.

Template Parameters
TListThe list type.
Parameters
listThe source list.
Returns
The new inline list.
Type Constraints
TList :IReadOnlyList<T> 
readonly bool ILGPU.Util.InlineList< T >.Equals< TComparer > ( InlineList< T >  other,
TComparer  comparer 
)

Returns true if the given list is equal to the current list.

Parameters
otherThe other list.
comparerThe comparer to use.
Returns
True, if the given list is equal to the current list.
Type Constraints
TComparer :IEqualityComparer<T> 
readonly ReadOnlySpan<T>.Enumerator ILGPU.Util.InlineList< T >.GetEnumerator ( )

Returns an enumerator to enumerate all items in this list.

Returns
The enumerator.

CAUTION: iterating over this list can be dangerous, as the underlying inline list might change and this instance is a structure value.

readonly int ILGPU.Util.InlineList< T >.IndexOf< TComparer > ( item,
TComparer  comparer 
)

Returns the index of the given item.

Parameters
itemThe item to look for.
comparerThe comparer to use.
Returns
The index of the item or -1.
Type Constraints
TComparer :IEqualityComparer<T> 
void ILGPU.Util.InlineList< T >.Insert ( item,
int  index 
)

Inserts the given item at the specified index.

Parameters
itemThe item to insert.
indexThe target index.
void ILGPU.Util.InlineList< T >.MoveTo ( ref InlineList< T >  list)

Moves the current items to the given target list.

Parameters
listThe target list to move to.
static implicit ILGPU.Util.InlineList< T >.operator ReadOnlySpan< T > ( InlineList< T >  list)
static

Converts the given list into a read-only span.

Parameters
listThe list to convert.
static ILGPU.Util.InlineList< T >.operator Span< T > ( InlineList< T >  list)
explicitstatic

Converts the given list into a span.

Parameters
listThe list to convert.
bool ILGPU.Util.InlineList< T >.Remove< TComparer > ( item,
TComparer  comparer 
)

Removes the given item from the list.

Parameters
itemThe item to remove.
comparerThe comparer to use.
Returns
True, if the item could be removed from the list.
Type Constraints
TComparer :IEqualityComparer<T> 
void ILGPU.Util.InlineList< T >.RemoveAt ( int  index)

Removes the item with the specified index.

Parameters
indexThe item index.
void ILGPU.Util.InlineList< T >.Reserve ( int  capacity)

Ensures that this list as at least the given capacity.

Parameters
capacityThe capacity to ensure.
void ILGPU.Util.InlineList< T >.Resize ( int  count)

Resizes the current list to have a sufficient capacity for all items while settings the number of elements to count .

Parameters
countThe desired number of elements.
void ILGPU.Util.InlineList< T >.Reverse ( )

Reverses all items in this list.

readonly InlineList<T> ILGPU.Util.InlineList< T >.Slice ( int  startIndex,
int  count 
)

Slices a sub inline list out of this one.

Parameters
startIndexThe start index to begin slicing.
countThe number of elements to slice.
Returns
The new inline list.
readonly void ILGPU.Util.InlineList< T >.SliceTo ( int  startIndex,
int  count,
ref InlineList< T >  list 
)

Slices a sub inline list out of this one into the given one.

Parameters
startIndexThe start index to begin slicing.
countThe number of elements to slice.
listThe target list.
static InlineList<T> ILGPU.Util.InlineList< T >.ToInlineList< T > ( this ReadOnlySpan< T >  span)
static

Creates a new inline list from the given span.

Template Parameters
TThe element type.
Parameters
spanThe span instance.
Returns
The created inline list.
readonly override string ILGPU.Util.InlineList< T >.ToString ( )

Returns the string representation of this list.

Returns
The string representation of this list.
static string ILGPU.Util.InlineList< T >.ToString< T, TFormatter > ( this ReadOnlySpan< T >  span,
TFormatter  formatter 
)
static

Returns the string representation of the given span.

Template Parameters
TThe element type.
TFormatterThe formatter type.
Parameters
spanThe span instance.
formatterThe custom formatter.
Returns
The string representation of this list.
Type Constraints
TFormatter :IFormatter<T> 
readonly string ILGPU.Util.InlineList< T >.ToString< TFormatter > ( TFormatter  formatter)

Returns the string representation of this list.

Returns
The string representation of this list.
Type Constraints
TFormatter :InlineList.IFormatter<T> 
TFormatter :AsReadOnlySpan() 
TFormatter :ToString 
TFormatter :formatter 

Member Data Documentation

readonly int ILGPU.Util.InlineList< T >.Capacity => items.Length

The total capacity.

readonly InlineList<T> ILGPU.Util.InlineList< T >.Empty = new InlineList<T>(0)
static

An empty inline list.

Property Documentation

int ILGPU.Util.InlineList< T >.Count
get

Returns the number of items.

readonly ref T ILGPU.Util.InlineList< T >.this[int index]
get

Returns a reference to the i-th item.

Parameters
indexThe item index.
Returns
The item reference.

The documentation for this class was generated from the following file: