Search Results for

    Show / Hide Table of Contents

    Struct FreeList

    An array where indices are allocated from and stored in an in-place linked list. Allocating or deallocating a single int from this array is very fast, as is single datum lookup, but neither the allocated indices nor the free indices can be reliably iterated without an external data structure. This structure can be adapted to an arbitrary of external, parallel arrays.

    Namespace: GDX.Collections
    Syntax
    public struct FreeList

    Constructors

    | Improve this Doc View Source

    FreeList(Int32)

    Declaration
    public FreeList(int initialCapacity)
    Parameters
    Type Name Description
    System.Int32 initialCapacity

    The initial capacity of the array.

    Fields

    | Improve this Doc View Source

    Count

    The total number of currently-allocated indices.

    Declaration
    public int Count
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    CurrentFreeIndex

    The next available index of the free-list.

    Declaration
    public int CurrentFreeIndex
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Indices

    Data storage for allocated indices as well as the in-place free-list.

    Declaration
    public int[] Indices
    Field Value
    Type Description
    System.Int32[]

    Methods

    | Improve this Doc View Source

    AddUnchecked(Int32)

    Allocates an index from the free-list and stores an integer there, without checking for expansion.

    Declaration
    public int AddUnchecked(int data)
    Parameters
    Type Name Description
    System.Int32 data

    The integer value to store at the allocated index.

    Returns
    Type Description
    System.Int32

    The index allocated from the free-list.

    | Improve this Doc View Source

    AddWithExpandCheck(Int32, out Int32)

    Allocates an index from the free-list and stores an integer there, expanding the array by twice the current size if necessary.

    Declaration
    public bool AddWithExpandCheck(int data, out int allocatedIndex)
    Parameters
    Type Name Description
    System.Int32 data

    The integer value to store at the allocated index.

    System.Int32 allocatedIndex

    The index allocated from the free-list.

    Returns
    Type Description
    System.Boolean

    True if the array expanded.

    | Improve this Doc View Source

    AddWithExpandCheck(Int32, out Int32, Int32)

    Allocates an index from the free-list and stores an integer there, expanding the array if necessary.

    Declaration
    public bool AddWithExpandCheck(int data, out int allocatedIndex, int expandBy)
    Parameters
    Type Name Description
    System.Int32 data

    The integer value to store at the allocated index.

    System.Int32 allocatedIndex

    The index allocated from the free-list.

    System.Int32 expandBy

    How much the array should expand by when out of space.

    Returns
    Type Description
    System.Boolean

    True if the array expanded.

    | Improve this Doc View Source

    Clear()

    Removes all allocated data and rebuilds the free-list.

    Declaration
    public void Clear()
    | Improve this Doc View Source

    GetAndRemoveAt(Int32)

    Retrieves the value stored at the given index and deallocates the index, adding it to the free-list.

    Declaration
    public int GetAndRemoveAt(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The index to add to the free-list.

    Returns
    Type Description
    System.Int32

    The value stored at the given index.

    | Improve this Doc View Source

    RemoveAt(Int32)

    Deallocates the given index and adds it to the free-list.

    Declaration
    public void RemoveAt(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The index to add to the free-list.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Built on 2024-01-01 against 1f69a68.
    Generated by Dox+DocFX.