Array3DT Structure

Represents a cubic array, whose indexer access is faster than a regular 3D array. It supports accessing its planes as Array2DT instances, or the whole content as a single dimensional ArraySectionT or ArraySegmentT. Depending on the used platform it supports ArrayPoolT allocation and casting to SpanT.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
[SerializableAttribute]
public struct Array3D<T> : IDisposable, IEquatable<Array3D<T>>, 
	IEnumerable<T>, IEnumerable
Inheritance
Object    ValueType    Array3DT
Implements
IEnumerableT, IEnumerable, IDisposable, IEquatableArray3DT

Type Parameters

T
The type of the elements in the collection.

Remarks

In .NET Core 2.1/.NET Standard 2.1 and above an Array3DT instance can be easily turned to a SpanT instance (either by cast or by the AsSpan property).

The actual underlying single dimensional array can be accessed via the Buffer property that has an UnderlyingArray property.

If the current platform supports it, the underlying array might be obtained by using the ArrayPoolT.

  Note

Unlike the underlying ArraySectionT, the Array3DT implements the IDisposable interface. Calling the Dispose method is required if the Array3DT was not created from an existing ArraySectionT instance. Not calling the Dispose method may lead to decreased application performance.

Due to the Dispose method Array3DT is a non-readonly struct. It is not recommended to use it as a readonly field; otherwise, accessing its members would make the pre-C# 8.0 compilers to create defensive copies, which leads to a slight performance degradation.

Constructors

Array3DT(Int32, Int32, Int32) Initializes a new instance of the Array3DT struct using the specified depth, height and width. Parameter order is the same as in case of instantiating a regular three-dimensional array.
If the created Array3DT is not used anymore the Dispose method should be called to return the possibly ArrayPoolT-allocated underlying buffer to the pool.
Array3DT(ArraySectionT, Int32, Int32, Int32) Initializes a new instance of the Array3DT struct from an existing ArraySectionT using the specified depth, height and width. No heap allocation occurs when using this constructor overload.

Properties

AsMemory Returns the current Array3DT instance as a MemoryT instance.
AsSpan Returns the current Array3DT instance as a SpanT instance.
Buffer Gets the underlying buffer as a single dimensional ArraySectionT.
Depth Gets the depth of this Array3DT instance.
Height Gets the height of this Array3DT instance.
IsNull Gets whether this Array3DT instance represents a array.
Please note that the ToArray/To3DArray/ToJaggedArray methods return when this property returns .
IsNullOrEmpty Gets whether this Array3DT instance represents an empty or a array.
ItemIndex Gets a plane of the Array3DT as an Array2DT instance.
ItemInt32 Gets a plane of the Array3DT as an Array2DT instance.
ItemRange Gets a new Array3DT instance, which represents a subrange of planes of the current instance indicated by the specified range.
ItemInt32, Int32, Int32 Gets or sets the element at the specified indices. Parameter order is the same as in case of a regular three-dimensional array.
To return a reference to an element use the GetElementReference method instead.
Length Gets the total length of this Array3DT instance.
Width Gets the width of this Array3DT instance.

Methods

Dispose Releases the underlying buffer. If this Array3DT instance was instantiated by the self allocating constructor, then this method must be called when the Array3DT is not used anymore. On platforms that do not support the ArrayPoolT class this method simply clears the self instance.
Equals(Array3DT) Indicates whether the current Array3DT instance is equal to another one specified in the other parameter.
Equals(Object) Determines whether the specified object is equal to this instance.
(Overrides ValueTypeEquals(Object))
GetElementReference Gets the reference to the element at the specified indices. Parameter order is the same as in case of a regular three-dimensional array.
GetEnumerator Returns an enumerator that iterates through the items of this Array3DT.
GetHashCode Returns a hash code for this Array3DT instance.
(Overrides ValueTypeGetHashCode)
GetPinnableReference Returns a reference to the first element in this Array3DT. This makes possible to use the Array3DT in a fixed statement.
Slice(Int32) Gets a new Array3DT instance, which represents a subrange of planes of the current instance starting with the specified startPlaneIndex.
Slice(Int32, Int32) Gets a new Array3DT instance, which represents a subrange of planes of the current instance indicated by the specified startPlaneIndex and planeCount.
To3DArray Copies the elements of this Array3DT to a new three dimensional array.
ToArray Copies the elements of this Array3DT to a new single dimensional array.
ToJaggedArray Copies the elements of this Array3DT to a new jagged array.

Operators

Equality(Array3DT, Array3DT) Determines whether two specified Array3DT instances have the same value.
(Array3DT to ArraySectionT) Performs an implicit conversion from Array3DT to ArraySectionT.
(Array3DT to ArraySegmentT) Performs an implicit conversion from Array3DT to ArraySegmentT.
(Array3DT to SpanT) Performs an implicit conversion from Array3DT to SpanT.
Inequality(Array3DT, Array3DT) Determines whether two specified Array3DT instances have different values.

Extension Methods

Convert Converts an Object specified in the obj parameter to the desired targetType.
See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example.
(Defined by ObjectExtensions)
ConvertTTarget Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions)
ForEachT Similarly to the List<T>.ForEach method, processes an action on each element of an enumerable collection.
(Defined by EnumerableExtensions)
GetRandomElementT Gets a random element from the enumerable source using a new FastRandom instance.
(Defined by EnumerableExtensions)
GetRandomElementT Gets a random element from the enumerable source using a specified Random instance.
(Defined by EnumerableExtensions)
In Gets whether item is among the elements of set.
See the Examples section of the generic InT(T, T) overload for an example.
(Defined by ObjectExtensions)
IndexOf Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions)
IndexOf Searches for an element in the source enumeration.
(Defined by EnumerableExtensions)
IndexOfT Searches for an element in the source enumeration.
(Defined by EnumerableExtensions)
IndexOfT Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions)
IsNullOrEmpty Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions)
IsNullOrEmptyT Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions)
JoinT Concatenates the items of the source collection into a new string instance using the specified separator between the items.
(Defined by EnumerableExtensions)
JoinT Concatenates the items of the source collection into a new string instance using the specified separator between the items.
(Defined by EnumerableExtensions)
ShuffleT Shuffles an enumerable source (randomizes its elements) using a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleT Shuffles an enumerable source (randomizes its elements) using the provided seed with a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleT Shuffles an enumerable source (randomizes its elements) using the provided seed with a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleT Shuffles an enumerable source (randomizes its elements) using a specified Random instance.
(Defined by EnumerableExtensions)
ToCircularListT Creates a CircularListT from an IEnumerableT.
(Defined by EnumerableExtensions)
ToStringKeyedDictionaryT Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified keySelector delegate and a comparer.
(Defined by EnumerableExtensions)
ToStringKeyedDictionaryT, TValue Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified key and value selector delegates and a comparer.
(Defined by EnumerableExtensions)
TryAdd Tries to add the specified item to the collection.
(Defined by EnumerableExtensions)
TryAddT Tries to add the specified item to the collection.
(Defined by EnumerableExtensions)
TryAddRange Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions)
TryAddRangeT Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions)
TryClear Tries to remove all elements from the collection.
(Defined by EnumerableExtensions)
TryClearT Tries to remove all elements from the collection.
(Defined by EnumerableExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryGetCount Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions)
TryGetCountT Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions)
TryGetElementAt Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions)
TryGetElementAtT Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions)
TryInsert Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions)
TryInsertT Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions)
TryInsertRange Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions)
TryInsertRangeT Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions)
TryRemove Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions)
TryRemoveT Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions)
TryRemoveAt Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions)
TryRemoveAtT Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions)
TryRemoveRange Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions)
TryRemoveRangeT Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions)
TryReplaceRange Tries to remove count amount of items from the target at the specified index, and to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions)
TryReplaceRangeT Tries to remove count amount of items from the target at the specified index, and to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions)
TrySetElementAt Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions)
TrySetElementAtT Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions)

See Also