Gorgon
Show / Hide Table of Contents

Class GorgonArray<T>

A special array type that is used to monitor and track changes to itself.

Inheritance
object
GorgonArray<T>
GorgonConstantBuffers
GorgonReadWriteViewBindings
GorgonSamplerStates
GorgonShaderResourceViews
GorgonStreamOutBindings
GorgonVertexBufferBindings
Implements
IList<T>
ICollection<T>
IGorgonReadOnlyArray<T>
IReadOnlyList<T>
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable
IEquatable<IReadOnlyList<T>>
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.Collections
Assembly: Gorgon.Core.dll
Syntax
public class GorgonArray<T> : IList<T>, ICollection<T>, IGorgonReadOnlyArray<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IEquatable<IReadOnlyList<T>> where T : IEquatable<T>
Type Parameters
Name Description
T

The type of data in the array.

Constructors

| Edit this page View Source

GorgonArray(int)

Initializes a new instance of the GorgonArray<T> class.

Declaration
public GorgonArray(int maxSize)
Parameters
Type Name Description
int maxSize

The maximum size.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown if maxSize is less than 1, or larger than 64.

Properties

| Edit this page View Source

BackingArray

Property to return the backing store to objects that need it.

Declaration
protected T[] BackingArray { get; }
Property Value
Type Description
T[]
| Edit this page View Source

IsDirty

Property to return whether or not the list is dirty.

Declaration
public bool IsDirty { get; }
Property Value
Type Description
bool
| Edit this page View Source

this[int]

Gets or sets the element at the specified index.

Declaration
public T this[int index] { get; set; }
Parameters
Type Name Description
int index
Property Value
Type Description
T

The element at the specified index.

| Edit this page View Source

Length

Property to return the length of the array.

Declaration
public int Length { get; }
Property Value
Type Description
int

Methods

| Edit this page View Source

AsMemory()

Function to return read only memory for a slice of the array.

Declaration
public ReadOnlyMemory<T> AsMemory()
Returns
Type Description
ReadOnlyMemory<T>

The read only memory for the array slice.

| Edit this page View Source

AsMemory(int, int)

Function to return read only memory for a slice of the array.

Declaration
public ReadOnlyMemory<T> AsMemory(int start, int count)
Parameters
Type Name Description
int start

The starting index for the array.

int count

The number of items to slice.

Returns
Type Description
ReadOnlyMemory<T>

The read only memory for the array slice.

| Edit this page View Source

AsSpan()

Function to return a read only span for the array.

Declaration
public ReadOnlySpan<T> AsSpan()
Returns
Type Description
ReadOnlySpan<T>

The read only span for the array.

| Edit this page View Source

AsSpan(int, int)

Function to return a read only span for a slice of the array.

Declaration
public ReadOnlySpan<T> AsSpan(int start, int count)
Parameters
Type Name Description
int start

The starting index for the array.

int count

The number of items to slice.

Returns
Type Description
ReadOnlySpan<T>

The read only span for the array slice.

| Edit this page View Source

Clear()

Removes all items from the ICollection<T>.

Declaration
public void Clear()
Exceptions
Type Condition
NotSupportedException

The ICollection<T> is read-only.

| Edit this page View Source

Contains(T)

Determines whether the ICollection<T> contains a specific value.

Declaration
public bool Contains(T item)
Parameters
Type Name Description
T item

The object to locate in the ICollection<T>.

Returns
Type Description
bool

true if item is found in the ICollection<T>; otherwise, false.

| Edit this page View Source

CopyDirty(GorgonArray<T>)

Function to copy the dirty entries for this array into the specified array.

Declaration
public void CopyDirty(GorgonArray<T> array)
Parameters
Type Name Description
GorgonArray<T> array

The array that will receive the dirty entries.

Exceptions
Type Condition
ArgumentNullException

Thrown when the array parameter is null.

| Edit this page View Source

CopyTo(GorgonArray<T>, int)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

Declaration
public void CopyTo(GorgonArray<T> array, int destIndex = 0)
Parameters
Type Name Description
GorgonArray<T> array

The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.

int destIndex

[Optional] The destination index in this array to start writing into.

Exceptions
Type Condition
ArgumentNullException

array == null.

| Edit this page View Source

CopyTo(T[], int)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type Name Description
T[] array

The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.

int arrayIndex

The zero-based index in array at which copying begins.

Exceptions
Type Condition
ArgumentNullException

array == null.

ArgumentOutOfRangeException

arrayIndex is less than 0.

ArgumentException

The number of elements in the source ICollection<T> is greater than the available space from arrayIndex to the end of the destination array.

| Edit this page View Source

DirtyEquals(IGorgonReadOnlyArray<T>, int)

Indicates whether the current object is equal to another object of the same type.

Declaration
public bool DirtyEquals(IGorgonReadOnlyArray<T> other, int offset = 0)
Parameters
Type Name Description
IGorgonReadOnlyArray<T> other

An object to compare with this object.

int offset

[Optional] The offset in this array to start comparing from.

Returns
Type Description
bool

true if the current object is equal to the other parameter; otherwise, false.

| Edit this page View Source

Equals(IReadOnlyList<T>)

Indicates whether the current object is equal to another object of the same type.

Declaration
public bool Equals(IReadOnlyList<T> other)
Parameters
Type Name Description
IReadOnlyList<T> other

An object to compare with this object.

Returns
Type Description
bool

true if the current object is equal to the other parameter; otherwise, false.

| Edit this page View Source

GetDirtyItems(bool)

Function to retrieve the dirty items in this list.

Declaration
public ref readonly (int Start, int Count) GetDirtyItems(bool peek = false)
Parameters
Type Name Description
bool peek

[Optional] true if the dirty state should not be modified by calling this method, or false if it should be.

Returns
Type Description
(int Start, int Count)

A tuple containing the starting index and the number of items.

Remarks

This will return a tuple that contains the start index, and count of the items that have been changed in this collection.

If the peek parameter is set to true, then the state of this collection is not changed when retrieving the modified objects. Otherwise, the state will be reset and a subsequent call to this method will result in a tuple that does not contain any changed values (i.e. the start and count will be 0) until the collection is modified again.

| Edit this page View Source

GetEnumerator()

Returns an enumerator that iterates through the collection.

Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type Description
IEnumerator<T>

An enumerator that can be used to iterate through the collection.

| Edit this page View Source

IndexOf(T)

Determines the index of a specific item in the IList<T>.

Declaration
public int IndexOf(T item)
Parameters
Type Name Description
T item

The object to locate in the IList<T>.

Returns
Type Description
int

The index of item if found in the list; otherwise, -1.

| Edit this page View Source

MarkDirty(Range)

Function to mark the specified range of indices as dirty.

Declaration
public void MarkDirty(Range range)
Parameters
Type Name Description
Range range

The range to mark dirty.

| Edit this page View Source

OnAssignDirtyItem(int, T)

Function called when a dirty item is assigned.

Declaration
protected virtual void OnAssignDirtyItem(int dirtyIndex, T value)
Parameters
Type Name Description
int dirtyIndex

The index that is considered dirty.

T value

The dirty value.

| Edit this page View Source

OnClear()

Function called when the array is cleared.

Declaration
protected virtual void OnClear()
| Edit this page View Source

OnItemReset(int, T)

Function called when an item is reset at an index.

Declaration
protected virtual void OnItemReset(int index, T oldItem)
Parameters
Type Name Description
int index

The index of the item that was assigned.

T oldItem

The previous item in the slot.

| Edit this page View Source

OnValidate()

Function to validate an item being assigned to a slot.

Declaration
protected virtual void OnValidate()
| Edit this page View Source

ResetAt(int)

Function to reset the value at the specified index, and remove it from the dirty range.

Declaration
public void ResetAt(int index)
Parameters
Type Name Description
int index

The index of the item to reset.

Exceptions
Type Condition
ArgumentOutOfRangeException

index is not a valid index in the IList<T>.

Implements

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

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonTreeLinqExtensions.TraverseDepthFirst<T>(IEnumerable<T>, Func<T, IEnumerable<T>>)
GorgonTreeLinqExtensions.Traverse<T>(IEnumerable<T>, Func<T, IEnumerable<T>>)
GorgonIReadOnlyListExtensions.Contains<T>(IReadOnlyList<T>, T)
GorgonIReadOnlyListExtensions.CopyTo<T>(IReadOnlyList<T>, T[])
GorgonIReadOnlyListExtensions.FirstIndexOf<T>(IReadOnlyList<T>, Predicate<T>)
GorgonIReadOnlyListExtensions.IndexOf<T>(IReadOnlyList<T>, T)
GorgonIReadOnlyListExtensions.LastIndexOf<T>(IReadOnlyList<T>, Predicate<T>)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author