CommunityToolkit.HighPerformance A that represents a boxed value on the managed heap. This is a "shadow" type that can be used in place of a non-generic reference to a boxed value type, to make the code more expressive and reduce the chances of errors. Consider this example: object obj = 42; // Manual, error prone unboxing int sum = (int)obj + 1; In this example, it is not possible to know in advance what type is actually being boxed in a given instance, making the code less robust at build time. The type can be used as a drop-in replacement in this case, like so: Box<int> box = 42; // Build-time validation, automatic unboxing int sum = box.Value + 1; This type can also be useful when dealing with large custom value types that are also boxed, as it allows to retrieve a mutable reference to the boxing value. This means that a given boxed value can be mutated in-place, instead of having to allocate a new updated boxed instance. The type of value being boxed. Initializes a new instance of the class. This constructor is never used, it is only declared in order to mark it with the visibility modifier and prevent direct use. Always thrown when this constructor is used (eg. from reflection). Returns a reference from the input instance. The input instance, representing a boxed value. A reference pointing to . Returns a reference from the input instance. The input instance, representing a boxed value. A reference pointing to . This method doesn't check the actual type of , so it is responsibility of the caller to ensure it actually represents a boxed value and not some other instance. Tries to get a reference from an input representing a boxed value. The input instance to check. The resulting reference, if was a boxed value. if a instance was retrieved correctly, otherwise. Implicitly gets the value from a given instance. The input instance. Implicitly creates a new instance from a given value. The input value to wrap. Throws an when a cast from an invalid is attempted. Helpers for working with the type. Gets a reference from a instance. The type of reference to retrieve. The input instance. A reference to the boxed value within . Represents a heap-based, array-backed output sink into which data can be written. The type of items to write to the current instance. This is a custom implementation that replicates the functionality and API surface of the array-based buffer writer available in .NET Standard 2.1, with the main difference being the fact that in this case the arrays in use are rented from the shared instance, and that is also available on .NET Standard 2.0. The default buffer size to use to expand empty arrays. The instance used to rent . The underlying array. The starting offset within . Initializes a new instance of the class. Initializes a new instance of the class. The instance to use. Initializes a new instance of the class. The minimum capacity with which to initialize the underlying buffer. Thrown when is not valid. Initializes a new instance of the class. The instance to use. The minimum capacity with which to initialize the underlying buffer. Thrown when is not valid. Gets an instance wrapping the underlying array in use. An instance wrapping the underlying array in use. Thrown when the buffer in use has already been disposed. This method is meant to be used when working with APIs that only accept an array as input, and should be used with caution. In particular, the returned array is rented from an array pool, and it is responsibility of the caller to ensure that it's not used after the current instance is disposed. Doing so is considered undefined behavior, as the same array might be in use within another instance. Ensures that has enough free space to contain a given number of new items. The minimum number of items to ensure space for in . Resizes to ensure it can fit the specified number of new items. The minimum number of items to ensure space for in . Throws an when the requested count is negative. Throws an when the size hint is negative. Throws an when the requested count is negative. Throws an when is . An that indicates a mode to use when allocating buffers. The default allocation mode for pooled memory (rented buffers are not cleared). Clear pooled buffers when renting them. An interface that expands with the ability to also inspect the written data, and to reset the underlying buffer to write again from the start. The type of items in the current buffer. Gets the data written to the underlying buffer so far, as a . Gets the data written to the underlying buffer so far, as a . Gets the amount of data written to the underlying buffer so far. Gets the total amount of space within the underlying buffer. Gets the amount of space available that can still be written into without forcing the underlying buffer to grow. Clears the data written to the underlying buffer. You must clear the instance before trying to re-use it. A custom that casts data from a array, to values. The source type of items to read. The target type to cast the source items to. The source array to read data from. The starting offset within . The original used length for . Initializes a new instance of the class. The source array to read data from. The starting offset within . The original used length for . Throws an when the target index for is invalid. An interface for a instance that can reinterpret its underlying data. Creates a new that reinterprets the underlying data for the current instance. The target type to cast the items to. The starting offset within the data store. The original used length for the data store. A new instance of the specified type, reinterpreting the current items. A custom that casts data from a of , to values. The source type of items to read. The target type to cast the source items to. The source to read data from. The starting offset within . The original used length for . Initializes a new instance of the class. The source to read data from. The starting offset within . The original used length for . Throws an when the target index for is invalid. Throws an when receives an invalid target index. A custom that can wrap arbitrary instances. The type of elements in the target memory area. The target instance. The initial offset within . The length of the target memory area. Initializes a new instance of the class. The target instance. The starting offset within . The usable length within . Throws an when the input index for is not valid. A custom that casts data from a to values. The target type to cast the source characters to. The source to read data from. The starting offset within . The original used length for . Initializes a new instance of the class. The source to read data from. The starting offset within . The original used length for . Throws an when the target index for is invalid. Represents an output sink into which data can be written, backed by a instance. The type of items to write to the current instance. This is a custom implementation that wraps a instance. It can be used to bridge APIs consuming an with existing instances (or objects that can be converted to a ), to ensure the data is written directly to the intended buffer, with no possibility of doing additional allocations or expanding the available capacity. The underlying instance. The starting offset within . Initializes a new instance of the class. The target instance to write to. Validates the requested size for either or . The minimum number of items to ensure space for in . Throws an when the requested count is negative. Throws an when the size hint is negative. Throws an when the requested count is negative. Throws an when the requested size exceeds the capacity. An implementation with an embedded length and a fast accessor. The type of items to store in the current instance. The starting offset within . The usable length within (starting from ). The instance used to rent . The underlying array. Initializes a new instance of the class with the specified parameters. The length of the new memory buffer to use. The instance to use. Indicates the allocation mode to use for the new buffer to rent. Initializes a new instance of the class with the specified parameters. The starting offset within . The length of the array to use. The instance currently in use. The input array to use. Gets an empty instance. Creates a new instance with the specified parameters. The length of the new memory buffer to use. A instance of the requested length. Thrown when is not valid. This method is just a proxy for the constructor, for clarity. Creates a new instance with the specified parameters. The length of the new memory buffer to use. The instance currently in use. A instance of the requested length. Thrown when is not valid. This method is just a proxy for the constructor, for clarity. Creates a new instance with the specified parameters. The length of the new memory buffer to use. Indicates the allocation mode to use for the new buffer to rent. A instance of the requested length. Thrown when is not valid. This method is just a proxy for the constructor, for clarity. Creates a new instance with the specified parameters. The length of the new memory buffer to use. The instance currently in use. Indicates the allocation mode to use for the new buffer to rent. A instance of the requested length. Thrown when is not valid. This method is just a proxy for the constructor, for clarity. Gets the number of items in the current instance Gets a wrapping the memory belonging to the current instance. Returns a reference to the first element within the current instance, with no bounds check. A reference to the first element within the current instance. Thrown when the buffer in use has already been disposed. This method does not perform bounds checks on the underlying buffer, but does check whether the buffer itself has been disposed or not. This check should not be removed, and it's also the reason why the method to get a reference at a specified offset is not present. Gets an instance wrapping the underlying array in use. An instance wrapping the underlying array in use. Thrown when the buffer in use has already been disposed. This method is meant to be used when working with APIs that only accept an array as input, and should be used with caution. In particular, the returned array is rented from an array pool, and it is responsibility of the caller to ensure that it's not used after the current instance is disposed. Doing so is considered undefined behavior, as the same array might be in use within another instance. Slices the buffer currently in use and returns a new instance. The starting offset within the current buffer. The length of the buffer to use. A new instance using the target range of items. Thrown when the buffer in use has already been disposed. Thrown when or are not valid. Using this method will dispose the current instance, and should only be used when an oversized buffer is rented and then adjusted in size, to avoid having to rent a new buffer of the new size and copy the previous items into the new one, or needing an additional variable/field to manually handle to track the used range within a given instance. Throws an when is . Throws an when the is invalid. Throws an when the is invalid. A stack-only type with the ability to rent a buffer of a specified length and getting a from it. This type mirrors but without allocations and with further optimizations. As this is a stack-only type, it relies on the duck-typed pattern introduced with C# 8. It should be used like so: using (SpanOwner<byte> buffer = SpanOwner<byte>.Allocate(1024)) { // Use the buffer here... } As soon as the code leaves the scope of that block, the underlying buffer will automatically be disposed. The APIs in rely on this pattern for extra performance, eg. they don't perform the additional checks that are done in to ensure that the buffer hasn't been disposed before returning a or instance from it. As such, this type should always be used with a block or expression. Not doing so will cause the underlying buffer not to be returned to the shared pool. The type of items to store in the current instance. The usable length within . The instance used to rent . The underlying array. Initializes a new instance of the struct with the specified parameters. The length of the new memory buffer to use. The instance to use. Indicates the allocation mode to use for the new buffer to rent. Gets an empty instance. Creates a new instance with the specified parameters. The length of the new memory buffer to use. A instance of the requested length. Thrown when is not valid. This method is just a proxy for the constructor, for clarity. Creates a new instance with the specified parameters. The length of the new memory buffer to use. The instance to use. A instance of the requested length. Thrown when is not valid. This method is just a proxy for the constructor, for clarity. Creates a new instance with the specified parameters. The length of the new memory buffer to use. Indicates the allocation mode to use for the new buffer to rent. A instance of the requested length. Thrown when is not valid. This method is just a proxy for the constructor, for clarity. Creates a new instance with the specified parameters. The length of the new memory buffer to use. The instance to use. Indicates the allocation mode to use for the new buffer to rent. A instance of the requested length. Thrown when is not valid. This method is just a proxy for the constructor, for clarity. Gets the number of items in the current instance Gets a wrapping the memory belonging to the current instance. Returns a reference to the first element within the current instance, with no bounds check. A reference to the first element within the current instance. Gets an instance wrapping the underlying array in use. An instance wrapping the underlying array in use. This method is meant to be used when working with APIs that only accept an array as input, and should be used with caution. In particular, the returned array is rented from an array pool, and it is responsibility of the caller to ensure that it's not used after the current instance is disposed. Doing so is considered undefined behavior, as the same array might be in use within another instance. Implements the duck-typed method. A configurable pool for instances. This can be used to minimize allocations when creating multiple instances from buffers of values. The method provides a best-effort alternative to just creating a new instance every time, in order to minimize the number of duplicated instances. The type will internally manage a highly efficient priority queue for the cached instances, so that when the full capacity is reached, the least frequently used values will be automatically discarded to leave room for new values to cache. The size used by default by the parameterless constructor. The minimum size for instances. The current array of instances in use. The total number of maps in use. Initializes a new instance of the class. Initializes a new instance of the class. The minimum size for the pool to create. Gets the shared instance. The shared pool provides a singleton, reusable instance that can be accessed directly, and that pools instances for the entire process. Since is thread-safe, the shared instance can be used concurrently by multiple threads without the need for manual synchronization. Gets the total number of that can be stored in the current instance. Stores a instance in the internal cache. The input instance to cache. Gets a cached instance matching the input content, or stores the input one. The input instance with the contents to use. A instance with the contents of , cached if possible. Gets a cached instance matching the input content, or creates a new one. The input with the contents to use. A instance with the contents of , cached if possible. Gets a cached instance matching the input content (converted to Unicode), or creates a new one. The input with the contents to use, in a specified encoding. The instance to use to decode the contents of . A instance with the contents of , cached if possible. Tries to get a cached instance matching the input content, if present. The input with the contents to use. The resulting cached instance, if present Whether or not the target instance was found. Resets the current instance and its associated maps. A configurable map containing a group of cached instances. Instances of this type are stored in an array within and they are always accessed by reference - essentially as if this type had been a class. The type is also private, so there's no risk for users to directly access it and accidentally copy an instance, which would lead to bugs due to values becoming out of sync with the internal state (that is, because instances would be copied by value, so primitive fields would not be shared). The reason why we're using a struct here is to remove an indirection level and improve cache locality when accessing individual buckets from the methods in the type. The index representing the end of a given list. The array of 1-based indices for the items stored in . The array of currently cached entries (ie. the lists for each hash group). The array of priority values associated to each item stored in . The current number of items stored in the map. The current incremental timestamp for the items stored in . A type representing a map entry, ie. a node in a given list. The precomputed hashcode for . The instance cached in this entry. The 0-based index for the next node in the current list. The 0-based index for the heap entry corresponding to the current node. A type representing a heap entry, used to associate priority to each item. The timestamp for the current entry (ie. the priority for the item). The 0-based index for the map entry corresponding to the current item. Initializes a new instance of the struct. The fixed capacity of the current map. Gets an that can be used to synchronize access to the current instance. Implements for the current instance. The input instance to cache. The precomputed hashcode for . Implements for the current instance. The input instance with the contents to use. The precomputed hashcode for . A instance with the contents of . Implements for the current instance. The input with the contents to use. The precomputed hashcode for . A instance with the contents of , cached if possible. Implements for the current instance. The input with the contents to use. The precomputed hashcode for . The resulting cached instance, if present Whether or not the target instance was found. Resets the current instance and throws away all the cached values. Tries to get a target instance, if it exists, and returns a reference to it. The input with the contents to use. The precomputed hashcode for . A reference to the slot where the target instance could be. Inserts a new instance in the current map, freeing up a space if needed. The new instance to store. The precomputed hashcode for . Removes a specified instance from the map to free up one slot. The precomputed hashcode of the instance to remove. The index of the target map node to remove. The input instance needs to already exist in the map. Updates the timestamp of a heap node at the specified index (which is then synced back). The index of the target heap node to update. Updates the timestamp of all the current heap nodes in incrementing order. The heap is always guaranteed to be complete binary tree, so when it contains a given number of nodes, those are all contiguous from the start of the array. Gets the (positive) hashcode for a given instance. The input instance. The hashcode for . Throws an when the requested size exceeds the capacity. A debug proxy used to display items in a 1D layout. The type of items to display. Initializes a new instance of the class with the specified parameters. The input instance with the items to display. Initializes a new instance of the class with the specified parameters. The input instance with the items to display. Initializes a new instance of the class with the specified parameters. The input instance with the items to display. Initializes a new instance of the class with the specified parameters. The input instance with the items to display. Gets the items to display for the current instance A that iterates readonly items from arbitrary memory locations. The type of items to enumerate. The instance pointing to the first item in the target memory area. The field maps to the total available length. The distance between items in the sequence to enumerate. The distance refers to items, not byte offset. Initializes a new instance of the struct. The instance pointing to the first item in the target memory area. The distance between items in the sequence to enumerate. Initializes a new instance of the struct. A reference to the first item of the sequence. The number of items in the sequence. The distance between items in the sequence to enumerate. Creates a new instance of the struct with the specified parameters. The reference to the first item to map. The number of items in the sequence. The distance between items in the sequence to enumerate. A instance with the specified parameters. Thrown when one of the parameters are negative. Gets the total available length for the sequence. Gets the element at the specified zero-based index. The zero-based index of the element. A reference to the element at the specified index. Thrown when is invalid. Gets the element at the specified zero-based index. The zero-based index of the element. A reference to the element at the specified index. Thrown when is invalid. Copies the contents of this into a destination instance. The destination instance. Thrown when is shorter than the source instance. Attempts to copy the current instance to a destination . The target of the copy operation. Whether or not the operation was successful. Copies the contents of this into a destination instance. The destination instance. Thrown when is shorter than the source instance. Attempts to copy the current instance to a destination . The target of the copy operation. Whether or not the operation was successful. Implicitly converts a instance into a one. The input instance. A custom enumerator type to traverse items within a instance. The current position in the sequence. Initializes a new instance of the struct. The instance with the info on the items to traverse. The distance between items in the sequence to enumerate. Throws an when the "length" parameter is invalid. Throws an when the "step" parameter is invalid. Throws an when the target span is too short. A that enumerates the items in a given instance. The type of items to enumerate. The source instance. The current index within . Initializes a new instance of the struct. The source instance. Implements the duck-typed method. An instance targeting the current value. Implements the duck-typed method. whether a new element is available, otherwise Gets the duck-typed property. An item from a source instance. The source instance. Initializes a new instance of the struct. A reference to the target value. The index of the target value. Gets the reference to the current value. Gets the current index. A that tokenizes a given instance. The type of items to enumerate. The source instance. The separator item to use. The current initial offset. The current final offset. Initializes a new instance of the struct. The source instance. The separator item to use. Implements the duck-typed method. An instance targeting the current value. Implements the duck-typed method. whether a new element is available, otherwise Gets the duck-typed property. A that iterates items from arbitrary memory locations. The type of items to enumerate. The instance pointing to the first item in the target memory area. The field maps to the total available length. The distance between items in the sequence to enumerate. The distance refers to items, not byte offset. Initializes a new instance of the struct. A reference to the first item of the sequence. The number of items in the sequence. The distance between items in the sequence to enumerate. Creates a new instance of the struct with the specified parameters. The reference to the first item to map. The number of items in the sequence. The distance between items in the sequence to enumerate. A instance with the specified parameters. Thrown when one of the parameters are negative. Gets the total available length for the sequence. Gets the element at the specified zero-based index. The zero-based index of the element. A reference to the element at the specified index. Thrown when is invalid. Gets the element at the specified zero-based index. The zero-based index of the element. A reference to the element at the specified index. Thrown when is invalid. Clears the contents of the current instance. Copies the contents of this into a destination instance. The destination instance. Thrown when is shorter than the source instance. Attempts to copy the current instance to a destination . The target of the copy operation. Whether or not the operation was successful. Copies the contents of this into a destination instance. The destination instance. Thrown when is shorter than the source instance. Attempts to copy the current instance to a destination . The target of the copy operation. Whether or not the operation was successful. Copies the contents of a source into the current instance. The source instance. Thrown when the current is shorter than the source instance. Attempts to copy the source into the current instance. The source instance. Whether or not the operation was successful. Fills the elements of this with a specified value. The value to assign to each element of the instance. Returns a array with the values in the target row. A array with the values in the target row. This method will allocate a new array, so only use it if you really need to copy the target items in a new memory location. A custom enumerator type to traverse items within a instance. The current position in the sequence. Initializes a new instance of the struct. The instance with the info on the items to traverse. The distance between items in the sequence to enumerate. Throws an when the "length" parameter is invalid. Throws an when the "step" parameter is invalid. Throws an when the target span is too short. A that enumerates the items in a given instance. The type of items to enumerate. The source instance. The current index within . Initializes a new instance of the struct. The source instance. Implements the duck-typed method. An instance targeting the current value. Implements the duck-typed method. whether a new element is available, otherwise Gets the duck-typed property. An item from a source instance. The source instance. Initializes a new instance of the struct. A reference to the target value. The index of the target value. Gets the reference to the current value. Gets the current index. A that tokenizes a given instance. The type of items to enumerate. The source instance. The separator item to use. The current initial offset. The current final offset. Initializes a new instance of the struct. The source instance. The separator item to use. Implements the duck-typed method. An instance targeting the current value. Implements the duck-typed method. whether a new element is available, otherwise Gets the duck-typed property. Helpers for working with the type. Returns a reference to the first element within a given array, with no bounds checks. The type of elements in the input array instance. The input array instance. A reference to the first element within , or the location it would have used, if is empty. This method doesn't do any bounds checks, therefore it is responsibility of the caller to perform checks in case the returned value is dereferenced. Returns a reference to an element at a specified index within a given array, with no bounds checks. The type of elements in the input array instance. The input array instance. The index of the element to retrieve within . A reference to the element within at the index specified by . This method doesn't do any bounds checks, therefore it is responsibility of the caller to ensure the parameter is valid. Counts the number of occurrences of a given value into a target array instance. The type of items in the input array instance. The input array instance. The value to look for. The number of occurrences of in . Enumerates the items in the input array instance, as pairs of reference/index values. This extension should be used directly within a loop: int[] numbers = new[] { 1, 2, 3, 4, 5, 6, 7 }; foreach (var item in numbers.Enumerate()) { // Access the index and value of each item here... int index = item.Index; ref int value = ref item.Value; } The compiler will take care of properly setting up the loop with the type returned from this method. The type of items to enumerate. The source array to enumerate. A wrapper type that will handle the reference/index enumeration for . The returned value shouldn't be used directly: use this extension in a loop. Tokenizes the values in the input array instance using a specified separator. This extension should be used directly within a loop: char[] text = "Hello, world!".ToCharArray(); foreach (var token in text.Tokenize(',')) { // Access the tokens here... } The compiler will take care of properly setting up the loop with the type returned from this method. The type of items in the array to tokenize. The source array to tokenize. The separator item to use. A wrapper type that will handle the tokenization for . The returned value shouldn't be used directly: use this extension in a loop. Gets a content hash from the input array instance using the Djb2 algorithm. For more info, see the documentation for . The type of items in the input array instance. The input array instance. The Djb2 value for the input array instance. The Djb2 hash is fully deterministic and with no random components. Checks whether or not a given array is covariant. The type of items in the input array instance. The input array instance. Whether or not is covariant. Throws an when the "column" parameter is invalid. Returns a reference to the first element within a given 2D array, with no bounds checks. The type of elements in the input 2D array instance. The input array instance. A reference to the first element within , or the location it would have used, if is empty. This method doesn't do any bounds checks, therefore it is responsibility of the caller to perform checks in case the returned value is dereferenced. Returns a reference to an element at a specified coordinate within a given 2D array, with no bounds checks. The type of elements in the input 2D array instance. The input 2D array instance. The vertical index of the element to retrieve within . The horizontal index of the element to retrieve within . A reference to the element within at the coordinate specified by and . This method doesn't do any bounds checks, therefore it is responsibility of the caller to ensure the and parameters are valid. Furthermore, this extension will ignore the lower bounds for the input array, and will just assume that the input index is 0-based. It is responsibility of the caller to adjust the input indices to account for the actual lower bounds, if the input array has either axis not starting at 0. Returns a over a row in a given 2D array instance. The type of elements in the input 2D array instance. The input array instance. The target row to retrieve (0-based index). A with the items from the target row within . The returned value shouldn't be used directly: use this extension in a loop. Thrown when one of the input parameters is out of range. Returns a that returns the items from a given column in a given 2D array instance. This extension should be used directly within a loop: int[,] matrix = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; foreach (ref int number in matrix.GetColumn(1)) { // Access the current number by reference here... } The compiler will take care of properly setting up the loop with the type returned from this method. The type of elements in the input 2D array instance. The input array instance. The target column to retrieve (0-based index). A wrapper type that will handle the column enumeration for . The returned value shouldn't be used directly: use this extension in a loop. Thrown when one of the input parameters is out of range. Creates a new over an input 2D array. The type of elements in the input 2D array instance. The input 2D array instance. A instance with the values of . Creates a new over an input 2D array. The type of elements in the input 2D array instance. The input 2D array instance. The target row to map within . The target column to map within . The height to map within . The width to map within . Thrown when doesn't match . Thrown when either , or are negative or not within the bounds that are valid for . A instance with the values of . Creates a new over an input 2D array. The type of elements in the input 2D array instance. The input 2D array instance. A instance with the values of . Creates a new over an input 2D array. The type of elements in the input 2D array instance. The input 2D array instance. The target row to map within . The target column to map within . The height to map within . The width to map within . Thrown when doesn't match . Thrown when either , or are negative or not within the bounds that are valid for . A instance with the values of . Returns a over a row in a given 2D array instance. The type of elements in the input 2D array instance. The input array instance. The target row to retrieve (0-based index). A with the items from the target row within . Thrown when doesn't match . Thrown when is invalid. Returns a over a row in a given 2D array instance. The type of elements in the input 2D array instance. The input array instance. The target row to retrieve (0-based index). A with the items from the target row within . Thrown when doesn't match . Thrown when is invalid. Creates a new over an input 2D array. The type of elements in the input 2D array instance. The input 2D array instance. A instance with the values of . Creates a new over an input 2D array. The type of elements in the input 2D array instance. The input 2D array instance. A instance with the values of . Counts the number of occurrences of a given value into a target 2D array instance. The type of items in the input 2D array instance. The input 2D array instance. The value to look for. The number of occurrences of in . Gets a content hash from the input 2D array instance using the Djb2 algorithm. For more info, see the documentation for . The type of items in the input 2D array instance. The input 2D array instance. The Djb2 value for the input 2D array instance. The Djb2 hash is fully deterministic and with no random components. Checks whether or not a given array is covariant. The type of items in the input array instance. The input array instance. Whether or not is covariant. Throws an when using an array of an invalid type. Throws an when the "row" parameter is invalid. Throws an when the "column" parameter is invalid. Returns a reference to the first element within a given 3D array, with no bounds checks. The type of elements in the input 3D array instance. The input array instance. A reference to the first element within , or the location it would have used, if is empty. This method doesn't do any bounds checks, therefore it is responsibility of the caller to perform checks in case the returned value is dereferenced. Returns a reference to an element at a specified coordinate within a given 3D array, with no bounds checks. The type of elements in the input 3D array instance. The input 2D array instance. The depth index of the element to retrieve within . The vertical index of the element to retrieve within . The horizontal index of the element to retrieve within . A reference to the element within at the coordinate specified by and . This method doesn't do any bounds checks, therefore it is responsibility of the caller to ensure the and parameters are valid. Furthermore, this extension will ignore the lower bounds for the input array, and will just assume that the input index is 0-based. It is responsibility of the caller to adjust the input indices to account for the actual lower bounds, if the input array has either axis not starting at 0. Creates a new over an input 3D array. The type of elements in the input 3D array instance. The input 3D array instance. A instance with the values of . Creates a new over an input 3D array. The type of elements in the input 3D array instance. The input 3D array instance. A instance with the values of . Creates a new instance of the struct wrapping a layer in a 3D array. The type of elements in the input 3D array instance. The given 3D array to wrap. The target layer to map within . Thrown when doesn't match . Thrown when is invalid. A instance wrapping the target layer within . Creates a new instance of the struct wrapping a layer in a 3D array. The type of elements in the input 3D array instance. The given 3D array to wrap. The target layer to map within . Thrown when doesn't match . Thrown when is invalid. A instance wrapping the target layer within . Creates a new instance of the struct wrapping a layer in a 3D array. The type of elements in the input 3D array instance. The given 3D array to wrap. The target layer to map within . Thrown when doesn't match . Thrown when either is invalid. A instance wrapping the target layer within . Creates a new instance of the struct wrapping a layer in a 3D array. The type of elements in the input 3D array instance. The given 3D array to wrap. The target layer to map within . Thrown when doesn't match . Thrown when either is invalid. A instance wrapping the target layer within . Counts the number of occurrences of a given value into a target 3D array instance. The type of items in the input 3D array instance. The input 3D array instance. The value to look for. The number of occurrences of in . Gets a content hash from the input 3D array instance using the Djb2 algorithm. For more info, see the documentation for . The type of items in the input 3D array instance. The input 3D array instance. The Djb2 value for the input 3D array instance. The Djb2 hash is fully deterministic and with no random components. Checks whether or not a given array is covariant. The type of items in the input array instance. The input array instance. Whether or not is covariant. Throws an when the "depth" parameter is invalid. Helpers for working with the type. Returns a that can be used to write to a target an of instance. The target instance. A wrapping and writing data to its underlying buffer. The returned can only be written to and does not support seeking. Helpers for working with the type. Changes the number of elements of a rented one-dimensional array to the specified new size. The type of items into the target array to resize. The target instance to use to resize the array. The rented array to resize, or to create a new array. The size of the new array. Indicates whether the contents of the array should be cleared before reuse. Thrown when is less than 0. When this method returns, the caller must not use any references to the old array anymore. Ensures that when the method returns is not null and is at least in length. Contents of are not copied if a new array is rented. The type of items into the target array given as input. The target instance used to rent and/or return the array. The rented array to ensure capacity for, or to rent a new array. The minimum length of when the method returns. Indicates whether the contents of the array should be cleared if returned to the pool. Thrown when is less than 0. When this method returns, the caller must not use any references to the old array anymore. Throws an when the "capacity" parameter is negative. Helpers for working with the type. Converts the given value into a . The input value to convert. 1 if is , 0 otherwise. This method does not contain branching instructions. Converts the given value to an mask with all bits representing the value of the input flag (either 0xFFFFFFFF or 0x00000000). The input value to convert. 0xFFFFFFFF if is , 0x00000000 otherwise. This method does not contain branching instructions, and it is only guaranteed to work with values being either 0 or 1. Operations producing a result, such as numerical comparisons, always result in a valid value. If the value is produced by fields with a custom , or by using or other unsafe APIs to directly manipulate the underlying data though, it is responsibility of the caller to ensure the validity of the provided value. Converts the given value to a mask with all bits representing the value of the input flag (either all 1s or 0s). The input value to convert. All 1s if is , all 0s otherwise. This method does not contain branching instructions. See additional note in . Helpers for working with the type. Adds a sequence of values to the hash code. The type of elements in the input instance. The input instance. The input instance. Helpers for working with the type. Returns a that can be used to write to a target an of instance. The target instance. A wrapping and writing data to its underlying buffer. The returned can only be written to and does not support seeking. Writes a value of a specified type into a target instance. The type of value to write. The target instance to write to. The input value to write to . Thrown if reaches the end. Writes a value of a specified type into a target instance. The type of value to write. The target instance to write to. The input value to write to . Thrown if reaches the end. Writes a series of items of a specified type into a target instance. The type of value to write. The target instance to write to. The input to write to . Thrown if reaches the end. Throws an when trying to write too many bytes to the target writer. Helpers for working with the type. Returns a wrapping the contents of the given of instance. The input of instance. A wrapping the data within . The caller does not need to track the lifetime of the input of instance, as the returned will take care of disposing that buffer when it is closed. Thrown when has an invalid data store. Helpers for working with the type. Returns a instance wrapping the underlying data for the given instance. The type of items in the input instance. The input instance. The height of the resulting 2D area. The width of each row in the resulting 2D area. The resulting instance. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Returns a instance wrapping the underlying data for the given instance. The type of items in the input instance. The input instance. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. The resulting instance. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Casts a of one primitive type to of bytes. The type if items in the source . The source , of type . A of bytes. Thrown if the property of the new would exceed . Thrown when the data store of is not supported. Casts a of one primitive type to another primitive type . The type of items in the source . The type of items in the destination . The source , of type . A of type Thrown when the data store of is not supported. Returns a wrapping the contents of the given of instance. The input of instance. A wrapping the data within . Since this method only receives a instance, which does not track the lifetime of its underlying buffer, it is responsibility of the caller to manage that. In particular, the caller must ensure that the target buffer is not disposed as long as the returned is in use, to avoid unexpected issues. Thrown when has an invalid data store. Helpers for working with the type. Returns a instance wrapping the underlying data for the given instance. The type of items in the input instance. The input instance. The height of the resulting 2D area. The width of each row in the resulting 2D area. The resulting instance. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Returns a instance wrapping the underlying data for the given instance. The type of items in the input instance. The input instance. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. The resulting instance. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Casts a of one primitive type to of bytes. The type if items in the source . The source , of type . A of bytes. Thrown if the property of the new would exceed . Thrown when the data store of is not supported. Casts a of one primitive type to another primitive type . The type of items in the source . The type of items in the destination . The source , of type . A of type Thrown when the data store of is not supported. Returns a wrapping the contents of the given of instance. The input of instance. A wrapping the data within . Since this method only receives a instance, which does not track the lifetime of its underlying buffer, it is responsibility of the caller to manage that. In particular, the caller must ensure that the target buffer is not disposed as long as the returned is in use, to avoid unexpected issues. Thrown when has an invalid data store. Helpers for working with the type. Returns a reference to the first element within a given , with no bounds checks. The type of elements in the input instance. The input instance. A reference to the first element within . This method doesn't do any bounds checks, therefore it is responsibility of the caller to perform checks in case the returned value is dereferenced. Returns a reference to an element at a specified index within a given , with no bounds checks. The type of elements in the input instance. The input instance. The index of the element to retrieve within . A reference to the element within at the index specified by . This method doesn't do any bounds checks, therefore it is responsibility of the caller to ensure the parameter is valid. Returns a reference to an element at a specified index within a given , with no bounds checks. The type of elements in the input instance. The input instance. The index of the element to retrieve within . A reference to the element within at the index specified by . This method doesn't do any bounds checks, therefore it is responsibility of the caller to ensure the parameter is valid. Returns a reference to the first element within a given , clamping the input index in the valid range. If the parameter exceeds the length of , it will be clamped to 0. Therefore, the returned reference will always point to a valid element within , assuming it is not empty. This method is specifically meant to efficiently index lookup tables, especially if they point to constant data. Consider this example where a lookup table is used to validate whether a given character is within a specific set: public static ReadOnlySpan<bool> ValidSetLookupTable => new bool[] { false, true, true, true, true, true, false, true, false, false, true, false, true, false, true, false, true, false, false, true, false, false, false, false, false, false, false, false, true, true, false, true }; int ch = Console.Read(); bool isValid = ValidSetLookupTable.DangerousGetLookupReference(ch); Even if the input index is outside the range of the lookup table, being clamped to 0, it will just cause the value 0 to be returned in this case, which is functionally the same for the check being performed. This extension can easily be used whenever the first position in a lookup table being referenced corresponds to a falsey value, like in this case. Additionally, the example above leverages a compiler optimization introduced with C# 7.3, which allows instances pointing to compile-time constant data to be directly mapped to the static .text section in the final assembly: the array being created in code will never actually be allocated, and the will just point to constant data. Note that this only works for blittable values that are not dependent on the byte endianness of the system, like or . For more info, see . The type of elements in the input instance. The input instance. The index of the element to retrieve within . A reference to the element within at the index specified by , or a reference to the first element within if was not a valid index. Returns a instance wrapping the underlying data for the given instance. The type of items in the input instance. The input instance. The height of the resulting 2D area. The width of each row in the resulting 2D area. The resulting instance. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Returns a instance wrapping the underlying data for the given instance. The type of items in the input instance. The input instance. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. The resulting instance. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Gets the index of an element of a given from its reference. The type if items in the input . The input to calculate the index for. The reference to the target item to get the index for. The index of within , or -1. Counts the number of occurrences of a given value into a target instance. The type of items in the input instance. The input instance to read. The value to look for. The number of occurrences of in . Casts a of one primitive type to of bytes. The type if items in the source . The source slice, of type . A of bytes. Thrown if the property of the new would exceed . Casts a of one primitive type to another primitive type . The type of items in the source . The type of items in the destination . The source slice, of type . A of type Supported only for platforms that support misaligned memory access or when the memory block is aligned by other means. Enumerates the items in the input instance, as pairs of value/index values. This extension should be used directly within a loop: ReadOnlySpan<string> words = new[] { "Hello", ", ", "world", "!" }; foreach (var item in words.Enumerate()) { // Access the index and value of each item here... int index = item.Index; string value = item.Value; } The compiler will take care of properly setting up the loop with the type returned from this method. The type of items to enumerate. The source to enumerate. A wrapper type that will handle the value/index enumeration for . The returned value shouldn't be used directly: use this extension in a loop. Tokenizes the values in the input instance using a specified separator. This extension should be used directly within a loop: ReadOnlySpan<char> text = "Hello, world!"; foreach (var token in text.Tokenize(',')) { // Access the tokens here... } The compiler will take care of properly setting up the loop with the type returned from this method. The type of items in the to tokenize. The source to tokenize. The separator item to use. A wrapper type that will handle the tokenization for . The returned value shouldn't be used directly: use this extension in a loop. Gets a content hash from the input instance using the Djb2 algorithm. It was designed by Daniel J. Bernstein and is a non-cryptographic has function. The main advantages of this algorithm are a good distribution of the resulting hash codes, which results in a relatively low number of collisions, while at the same time being particularly fast to process, making it suitable for quickly hashing even long sequences of values. For the reference implementation, see: . For details on the used constants, see the details provided in this StackOverflow answer (as well as the accepted one): . Additionally, a comparison between some common hashing algorithms can be found in the reply to this StackExchange question: . Note that the exact implementation is slightly different in this method when it is not called on a sequence of values: in this case the method will be invoked for each value in the provided instance, and then those values will be combined using the Djb2 algorithm. The type of items in the input instance. The input instance. The Djb2 value for the input instance. The Djb2 hash is fully deterministic and with no random components. Copies the contents of a given into destination instance. The type of items in the input instance. The input instance. The instance to copy items into. Thrown when the destination is shorter than the source . Attempts to copy the contents of a given into destination instance. The type of items in the input instance. The input instance. The instance to copy items into. Whether or not the operation was successful. Helpers for working with the type. Returns a reference to the first element within a given , with no bounds checks. The type of elements in the input instance. The input instance. A reference to the first element within . This method doesn't do any bounds checks, therefore it is responsibility of the caller to perform checks in case the returned value is dereferenced. Returns a reference to an element at a specified index within a given , with no bounds checks. The type of elements in the input instance. The input instance. The index of the element to retrieve within . A reference to the element within at the index specified by . This method doesn't do any bounds checks, therefore it is responsibility of the caller to ensure the parameter is valid. Returns a reference to an element at a specified index within a given , with no bounds checks. The type of elements in the input instance. The input instance. The index of the element to retrieve within . A reference to the element within at the index specified by . This method doesn't do any bounds checks, therefore it is responsibility of the caller to ensure the parameter is valid. Returns a instance wrapping the underlying data for the given instance. The type of items in the input instance. The input instance. The height of the resulting 2D area. The width of each row in the resulting 2D area. The resulting instance. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Returns a instance wrapping the underlying data for the given instance. The type of items in the input instance. The input instance. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. The resulting instance. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Casts a of one primitive type to of bytes. The type if items in the source . The source slice, of type . A of bytes. Thrown if the property of the new would exceed . Casts a of one primitive type to another primitive type . The type of items in the source . The type of items in the destination . The source slice, of type . A of type Supported only for platforms that support misaligned memory access or when the memory block is aligned by other means. Gets the index of an element of a given from its reference. The type if items in the input . The input to calculate the index for. The reference to the target item to get the index for. The index of within , or -1. Counts the number of occurrences of a given value into a target instance. The type of items in the input instance. The input instance to read. The value to look for. The number of occurrences of in . Enumerates the items in the input instance, as pairs of reference/index values. This extension should be used directly within a loop: Span<int> numbers = new[] { 1, 2, 3, 4, 5, 6, 7 }; foreach (var item in numbers.Enumerate()) { // Access the index and value of each item here... int index = item.Index; ref int value = ref item.Value; } The compiler will take care of properly setting up the loop with the type returned from this method. The type of items to enumerate. The source to enumerate. A wrapper type that will handle the reference/index enumeration for . The returned value shouldn't be used directly: use this extension in a loop. Tokenizes the values in the input instance using a specified separator. This extension should be used directly within a loop: Span<char> text = "Hello, world!".ToCharArray(); foreach (var token in text.Tokenize(',')) { // Access the tokens here... } The compiler will take care of properly setting up the loop with the type returned from this method. The type of items in the to tokenize. The source to tokenize. The separator item to use. A wrapper type that will handle the tokenization for . The returned value shouldn't be used directly: use this extension in a loop. Gets a content hash from the input instance using the Djb2 algorithm. For more info, see the documentation for . The type of items in the input instance. The input instance. The Djb2 value for the input instance. The Djb2 hash is fully deterministic and with no random components. Copies the contents of a given into destination instance. The type of items in the input instance. The input instance. The instance to copy items into. Thrown when the destination is shorter than the source . Attempts to copy the contents of a given into destination instance. The type of items in the input instance. The input instance. The instance to copy items into. Whether or not the operation was successful. Helpers for working with the type. Enters a specified instance and returns a wrapper to use to release the lock. This extension should be used though a block or statement: SpinLock spinLock = new SpinLock(); using (SpinLockExtensions.Enter(&spinLock)) { // Thread-safe code here... } The compiler will take care of releasing the SpinLock when the code goes out of that scope. A pointer to the target to use A wrapper type that will release when its method is called. The returned value shouldn't be used directly: use this extension in a block or statement. A that is used to enter and hold a through a block or statement. The * pointer to the target value to use. A value indicating whether or not the lock is taken by this instance. Initializes a new instance of the struct. The target to use. Implements the duck-typed method and releases the current instance. Helpers for working with the type. Asynchronously reads a sequence of bytes from a given instance. The source to read data from. The destination to write data to. The optional for the operation. A representing the operation being performed. Asynchronously writes a sequence of bytes to a given instance. The destination to write data to. The source to read data from. The optional for the operation. A representing the operation being performed. Reads a sequence of bytes from a given instance. The source to read data from. The target to write data to. The number of bytes that have been read. Writes a sequence of bytes to a given instance. The destination to write data to. The source to read data from. Reads a value of a specified type from a source instance. The type of value to read. The source instance to read from. The value read from . Thrown if reaches the end. Writes a value of a specified type into a target instance. The type of value to write. The target instance to write to. The input value to write to . Throws an when fails. Helpers for working with the type. Returns a reference to the first element within a given , with no bounds checks. The input instance. A reference to the first element within , or the location it would have used, if is empty. This method doesn't do any bounds checks, therefore it is responsibility of the caller to perform checks in case the returned value is dereferenced. Returns a reference to an element at a specified index within a given , with no bounds checks. The input instance. The index of the element to retrieve within . A reference to the element within at the index specified by . This method doesn't do any bounds checks, therefore it is responsibility of the caller to ensure the parameter is valid. Counts the number of occurrences of a given character into a target instance. The input instance to read. The character to look for. The number of occurrences of in . Enumerates the items in the input instance, as pairs of value/index values. This extension should be used directly within a loop: string text = "Hello, world!"; foreach (var item in text.Enumerate()) { // Access the index and value of each item here... int index = item.Index; char value = item.Value; } The compiler will take care of properly setting up the loop with the type returned from this method. The source to enumerate. A wrapper type that will handle the value/index enumeration for . The returned value shouldn't be used directly: use this extension in a loop. Tokenizes the values in the input instance using a specified separator. This extension should be used directly within a loop: string text = "Hello, world!"; foreach (var token in text.Tokenize(',')) { // Access the tokens here... } The compiler will take care of properly setting up the loop with the type returned from this method. The source to tokenize. The separator character to use. A wrapper type that will handle the tokenization for . The returned value shouldn't be used directly: use this extension in a loop. Gets a content hash from the input instance using the Djb2 algorithm. For more info, see the documentation for . The source to enumerate. The Djb2 value for the input instance. The Djb2 hash is fully deterministic and with no random components. Helpers to perform bit operations on numeric types. Checks whether or not a given bit is set. The input value. The position of the bit to check (in [0, 31] range). Whether or not the n-th bit is set. This method doesn't validate against the valid range. If the parameter is not valid, the result will just be inconsistent. Additionally, no conditional branches are used to retrieve the flag. Checks whether or not a given bit is set in a given bitwise lookup table. This method provides a branchless, register-based (with no memory accesses) way to check whether a given value is valid, according to a precomputed lookup table. It is similar in behavior to , with the main difference being that this method will also validate the input parameter, and will always return if it falls outside of the expected interval. Additionally, this method accepts a parameter, which is used to decrement the input parameter to ensure that the range of accepted values fits within the available 32 bits of the lookup table in use. For more info on this optimization technique, see . Here is how the code from the link above would be implemented using this method: bool IsReservedCharacter(char c) { return BitHelper.HasLookupFlag(314575237u, c, 36); } The resulted assembly is virtually identical, with the added optimization that the one produced by has no conditional branches at all. The input lookup table to use. The input value to check. The minimum accepted value for (defaults to 0). Whether or not the corresponding flag for is set in . For best results, as shown in the sample code, both and should be compile-time constants, so that the JIT compiler will be able to produce more efficient code. Checks whether the given value has any bytes that are set to 0. That is, given a value, which has a total of 4 bytes, it checks whether any of those have all the bits set to 0. The input value to check. Whether has any bytes set to 0. This method contains no branches. For more background on this subject, see . Checks whether the given value has any bytes that are set to 0. This method mirrors , but with values. The input value to check. Whether has any bytes set to 0. Checks whether a byte in the input value matches a target value. The input value to check. The target byte to look for. Whether has any bytes set to . This method contains no branches. For more info, see . Checks whether a byte in the input value matches a target value. This method mirrors , but with values. The input value to check. The target byte to look for. Whether has any bytes set to . Sets a bit to a specified value. The target value. The position of the bit to set or clear (in [0, 31] range). The value to assign to the target bit. Just like , this method doesn't validate and does not contain branching instructions, so it's well suited for use in tight loops as well. Sets a bit to a specified value. The input value. The position of the bit to set or clear (in [0, 31] range). The value to assign to the target bit. An value equal to except for the -th bit. Just like , this method doesn't validate and does not contain branching instructions, so it's well suited for use in tight loops as well. Extracts a bit field range from a given value. The input value. The initial index of the range to extract (in [0, 31] range). The length of the range to extract (depends on ). The value of the extracted range within . This method doesn't validate and . If either parameter is not valid, the result will just be inconsistent. The method should not be used to set all the bits at once, and it is not guaranteed to work in that case, which would just be equivalent to assigning the value. Additionally, no conditional branches are used to retrieve the range. Sets a bit field range within a target value. The target value. The initial index of the range to extract (in [0, 31] range). The length of the range to extract (depends on ). The input flags to insert in the target range. Just like , this method doesn't validate the parameters and does not contain branching instructions, so it's well suited for use in tight loops as well. Sets a bit field range within a target value. The initial value. The initial index of the range to extract (in [0, 31] range). The length of the range to extract (depends on ). The input flags to insert in the target range. The updated bit field value after setting the specified range. Just like , this method doesn't validate the parameters and does not contain branching instructions, so it's well suited for use in tight loops as well. Checks whether or not a given bit is set. The input value. The position of the bit to check (in [0, 63] range). Whether or not the n-th bit is set. This method doesn't validate against the valid range. If the parameter is not valid, the result will just be inconsistent. Additionally, no conditional branches are used to retrieve the flag. Checks whether or not a given bit is set in a given bitwise lookup table. For more info, check the XML docs of the overload. The input lookup table to use. The input value to check. The minimum accepted value for (defaults to 0). Whether or not the corresponding flag for is set in . For best results, as shown in the sample code, both and should be compile-time constants, so that the JIT compiler will be able to produce more efficient code. Sets a bit to a specified value. The target value. The position of the bit to set or clear (in [0, 63] range). The value to assign to the target bit. Just like , this method doesn't validate and does not contain branching instructions, so it's well suited for use in tight loops as well. Sets a bit to a specified value. The input value. The position of the bit to set or clear (in [0, 63] range). The value to assign to the target bit. An value equal to except for the -th bit. Just like , this method doesn't validate and does not contain branching instructions, so it's well suited for use in tight loops as well. Extracts a bit field range from a given value. The input value. The initial index of the range to extract (in [0, 63] range). The length of the range to extract (depends on ). The value of the extracted range within . This method doesn't validate and . If either parameter is not valid, the result will just be inconsistent. The method should not be used to set all the bits at once, and it is not guaranteed to work in that case, which would just be equivalent to assigning the value. Additionally, no conditional branches are used to retrieve the range. Sets a bit field range within a target value. The target value. The initial index of the range to extract (in [0, 63] range). The length of the range to extract (depends on ). The input flags to insert in the target range. Just like , this method doesn't validate the parameters and does not contain branching instructions, so it's well suited for use in tight loops as well. Sets a bit field range within a target value. The initial value. The initial index of the range to extract (in [0, 63] range). The length of the range to extract (depends on ). The input flags to insert in the target range. The updated bit field value after setting the specified range. Just like , this method doesn't validate the parameters and does not contain branching instructions, so it's well suited for use in tight loops as well. Combines the hash code of sequences of values into a single hash code. The type of values to hash. The hash codes returned by the method are only guaranteed to be repeatable for the current execution session, just like with the available APIs.In other words, hashing the same collection multiple times in the same process will always result in the same hash code, while the same collection being hashed again from another process (or another instance of the same process) is not guaranteed to result in the same final value. For more info, see . Gets a content hash from the input instance using the xxHash32 algorithm. The input instance The xxHash32 value for the input instance The xxHash32 is only guaranteed to be deterministic within the scope of a single app execution Gets a content hash from the input instance. The input instance The hash code for the input instance The returned hash code is not processed through APIs. Utility methods for intrinsic bit-twiddling operations. The methods use hardware intrinsics when available on the underlying platform, otherwise they use optimized software fallbacks. Round the given integral value up to a power of 2. The value. The smallest power of 2 which is greater than or equal to . If is 0 or the result overflows, returns 0. Helpers to process sequences of values by reference with a given step. Clears a target memory area. The type of values to clear. A reference to the start of the memory area. The number of items in the memory area. The number of items between each consecutive target value. Copies a sequence of discontiguous items from one memory area to another. The type of items to copy. The source reference to copy from. The target reference to copy to. The total number of items to copy. The step between consecutive items in the memory area pointed to by . Copies a sequence of discontiguous items from one memory area to another. The type of items to copy. The source reference to copy from. The target reference to copy to. The total number of items to copy. The step between consecutive items in the memory area pointed to by . The step between consecutive items in the memory area pointed to by . Copies a sequence of discontiguous items from one memory area to another. This mirrors , but refers to instead. The type of items to copy. The source reference to copy from. The target reference to copy to. The total number of items to copy. The step between consecutive items in the memory area pointed to by . Fills a target memory area. The type of values to fill. A reference to the start of the memory area. The number of items in the memory area. The number of items between each consecutive target value. The value to assign to every item in the target memory area. A helper class that with utility methods for dealing with references, and other low-level details. It also contains some APIs that act as polyfills for .NET Standard 2.0 and below. Converts a length of items from one size to another (rounding towards zero). The source type of items. The target type of items. The input length to convert. The converted length for the specified argument and types. Gets the length of a given array as a native integer. The type of values in the array. The input instance. The total length of as a native integer. This method is needed because this expression is not inlined correctly if the target array is only visible as a non-generic instance, because the C# compiler will not be able to emit the opcode instead of calling the right method. Gets the length of a given array as a native integer. The input instance. The total length of as a native integer. Gets the byte offset to the first element in a SZ array. The type of values in the array. The byte offset to the first element in a SZ array. Gets the byte offset to the first element in a 2D array. The type of values in the array. The byte offset to the first element in a 2D array. Gets the byte offset to the first element in a 3D array. The type of values in the array. The byte offset to the first element in a 3D array. A private generic class to preload type info for arbitrary runtime types. The type to load info for. The byte offset to the first element in a SZ array. The byte offset to the first element in a 2D array. The byte offset to the first element in a 3D array. Computes the value for . The value of for the current runtime. Computes the value for . The value of for the current runtime. Computes the value for . The value of for the current runtime. Helpers to process sequences of values by reference. Counts the number of occurrences of a given value into a target search space. A reference to the start of the search space. The number of items in the search space. The value to look for. The type of value to look for. The number of occurrences of in the search space Implements with a sequential search. Implements with a vectorized search. Gets the upper bound for partial sums with a given parameter. The type argument currently in use. The native value representing the upper bound. Casts a value of a given type to a native . The input type to cast. The input value to cast to native . The native cast of . Calculates the djb2 hash for the target sequence of items of a given type. The type of items to hash. The reference to the target memory area to hash. The number of items to hash. The Djb2 value for the input sequence of items. Gets a content hash from a given memory area. A reference to the start of the memory area. The size in bytes of the memory area. The hash code for the contents of the source memory area. While this method is similar to and can in some cases produce the same output for a given memory area, it is not guaranteed to always be that way. This is because this method can use SIMD instructions if possible, which can cause a computed hash to differ for the same data, if processed on different machines with different CPU features. The advantage of this method is that when SIMD instructions are available, it performs much faster than , as it can parallelize much of the workload. Helpers for working with instances. Calculates the byte offset to a specific field within a given . The type of field being referenced. The input hosting the target field. A reference to a target field of type within . The value representing the offset to the target field from the start of the object data for the parameter . The offset is in relation to the first usable byte after the method table. The input parameters are not validated, and it's responsibility of the caller to ensure that the reference is actually pointing to a memory location within . Gets a reference to data within a given at a specified offset. The type of reference to retrieve. The input hosting the target field. The input byte offset for the reference to retrieve. A reference at a specified offset within . None of the input arguments is validated, and it is responsibility of the caller to ensure they are valid. In particular, using an invalid offset might cause the retrieved reference to be misaligned with the desired data, which would break the type system. Or, if the offset causes the retrieved reference to point to a memory location outside of the input instance, that might lead to runtime crashes. Tries to get a boxed value from an input instance. The type of value to try to unbox. The input instance to check. The resulting value, if was in fact a boxed value. if a value was retrieved correctly, otherwise. This extension behaves just like the following method: public static bool TryUnbox<T>(object obj, out T value) { if (obj is T) { value = (T)obj; return true; } value = default; return false; } But in a more efficient way, and with the ability to also assign the unboxed value directly on an existing T variable, which is not possible with the code above. Unboxes a value from an input instance. The type of value to unbox. The input instance, representing a boxed value. The value boxed in . Thrown when is not of type . Helpers to work with parallel code in a highly optimized manner. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each iteration index. The iteration range. None of the bounds of can start from an end. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each iteration index. The iteration range. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. None of the bounds of can start from an end. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each iteration index. The iteration range. The instance representing the action to invoke. None of the bounds of can start from an end. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each iteration index. The iteration range. The instance representing the action to invoke. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. None of the bounds of can start from an end. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each iteration index. The starting iteration index. The final iteration index (exclusive). Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each iteration index. The starting iteration index. The final iteration index (exclusive). The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each iteration index. The starting iteration index. The final iteration index (exclusive). The instance representing the action to invoke. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each iteration index. The starting iteration index. The final iteration index (exclusive). The instance representing the action to invoke. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Processes the batch of actions at a specified index The index of the batch to process Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The value indicating the iteration range for the outer loop. The value indicating the iteration range for the inner loop. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The value indicating the iteration range for the outer loop. The value indicating the iteration range for the inner loop. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The value indicating the iteration range for the outer loop. The value indicating the iteration range for the inner loop. The instance representing the action to invoke. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The value indicating the iteration range for the outer loop. The value indicating the iteration range for the inner loop. The instance representing the action to invoke. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The value indicating the 2D iteration area to use. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The value indicating the 2D iteration area to use. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The value indicating the 2D iteration area to use. The instance representing the action to invoke. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The value indicating the 2D iteration area to use. The instance representing the action to invoke. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The starting iteration value for the outer loop. The final iteration value for the outer loop (exclusive). The starting iteration value for the inner loop. The final iteration value for the inner loop (exclusive). Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The starting iteration value for the outer loop. The final iteration value for the outer loop (exclusive). The starting iteration value for the inner loop. The final iteration value for the inner loop (exclusive). The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The starting iteration value for the outer loop. The final iteration value for the outer loop (exclusive). The starting iteration value for the inner loop. The final iteration value for the inner loop (exclusive). The instance representing the action to invoke. Executes a specified action in an optimized parallel loop. The type of action (implementing ) to invoke for each pair of iteration indices. The starting iteration value for the outer loop. The final iteration value for the outer loop (exclusive). The starting iteration value for the inner loop. The final iteration value for the inner loop (exclusive). The instance representing the action to invoke. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Processes the batch of actions at a specified index The index of the batch to process Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The instance representing the action to invoke. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The instance representing the action to invoke. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Processes the batch of actions at a specified index The index of the batch to process Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The instance representing the action to invoke. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The instance representing the action to invoke. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Processes the batch of actions at a specified index The index of the batch to process Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The instance representing the action to invoke. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The instance representing the action to invoke. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Processes the batch of actions at a specified index The index of the batch to process Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The instance representing the action to invoke. Executes a specified action in an optimized parallel loop over the input data. The type of items to iterate over. The type of action (implementing of ) to invoke over each item. The input representing the data to process. The instance representing the action to invoke. The minimum number of actions to run per individual thread. Set to 1 if all invocations should be parallelized, or to a greater number if each individual invocation is fast enough that it is more efficient to set a lower bound per each running thread. Processes the batch of actions at a specified index The index of the batch to process Throws an when an invalid parameter is specified for the minimum actions per thread. Throws an when an invalid start parameter is specified for 1D loops. Throws an when a range has an index starting from an end. Throws an when an invalid top parameter is specified for 2D loops. Throws an when an invalid left parameter is specified for 2D loops. A contract for actions being executed with an input index. If the method is small enough, it is highly recommended to mark it with . Executes the action associated with a specific index. The current index for the action to execute. A contract for actions being executed with two input indices. If the method is small enough, it is highly recommended to mark it with . Executes the action associated with two specified indices. The first index for the action to execute. The second index for the action to execute. A contract for actions being executed on items of a specific type, with readonly access. The type of items to process. If the method is small enough, it is highly recommended to mark it with . Executes the action on a specified item. The current item to process. A contract for actions being executed on items of a specific type, with side effect. The type of items to process. If the method is small enough, it is highly recommended to mark it with . Executes the action on a specified item. The current item to process. A helper to validate arithmetic operations for and . Ensures that the input parameters will not exceed the maximum native int value when indexing. The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map (the distance between each row). Throw when the inputs don't fit in the expected range. The input parameters are assumed to always be positive. Ensures that the input parameters will not exceed when indexing. The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map (the distance between each row). The area resulting from the given parameters. Throw when the inputs don't fit in the expected range. The input parameters are assumed to always be positive. A helper class to throw exceptions for memory types. Throws an when using the * constructor with a managed type. Throws an when the target span is too short. Throws an when the target span does not have the same shape as the source. Throws an when using an array of an invalid type. Throws an when using an array of an invalid type. Throws an when the a given coordinate is invalid. Throwing is technically discouraged in the docs, but we're doing that here for consistency with the official type(s) from the BCL. Throws an when more than one parameter are invalid. Throws an when the "depth" parameter is invalid. Throws an when the "row" parameter is invalid. Throws an when the "column" parameter is invalid. Throws an when the "offset" parameter is invalid. Throws an when the "height" parameter is invalid. Throws an when the "width" parameter is invalid. Throws an when the "pitch" parameter is invalid. A debug proxy used to display items in a 2D layout. The type of items to display. Initializes a new instance of the class with the specified parameters. The input instance with the items to display. Initializes a new instance of the class with the specified parameters. The input instance with the items to display. Initializes a new instance of the class with the specified parameters. The input instance with the items to display. Initializes a new instance of the class with the specified parameters. The input instance with the items to display. Gets the items to display for the current instance represents a 2D region of arbitrary memory. It is to what is to . For further details on how the internal layout is structured, see the docs for . The type can wrap arrays of any rank, provided that a valid series of parameters for the target memory area(s) are specified. The type of items in the current instance. The target instance, if present. The initial byte offset within . The height of the specified 2D region. The width of the specified 2D region. The pitch of the specified 2D region. Initializes a new instance of the struct. The target array to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when doesn't match . Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target array to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when doesn't match . Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Initializes a new instance of the struct wrapping a 2D array. The given 2D array to wrap. Thrown when doesn't match . Initializes a new instance of the struct wrapping a 2D array. The given 2D array to wrap. The target row to map within . The target column to map within . The height to map within . The width to map within . Thrown when doesn't match . Thrown when either , or are negative or not within the bounds that are valid for . Initializes a new instance of the struct wrapping a layer in a 3D array. The given 3D array to wrap. The target layer to map within . Thrown when doesn't match . Thrown when a parameter is invalid. Initializes a new instance of the struct wrapping a layer in a 3D array. The given 3D array to wrap. The target layer to map within . The target row to map within . The target column to map within . The height to map within . The width to map within . Thrown when doesn't match . Thrown when a parameter is invalid. Initializes a new instance of the struct. The target to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Initializes a new instance of the struct. The target to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Initializes a new instance of the struct with the specified parameters. The target instance. The initial offset within . The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map. Creates a new instance from an arbitrary object. The instance holding the data to map. The target reference to point to (it must be within ). The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map. A instance with the specified parameters. The parameter is not validated, and it's responsibility of the caller to ensure it's valid. Thrown when one of the input parameters is out of range. Gets an empty instance. Gets a value indicating whether the current instance is empty. Gets the length of the current instance. Gets the height of the underlying 2D memory area. Gets the width of the underlying 2D memory area. Gets a instance from the current memory. Slices the current instance with the specified parameters. The target range of rows to select. The target range of columns to select. Thrown when either or are invalid. A new instance representing a slice of the current one. Slices the current instance with the specified parameters. The target row to map within the current instance. The target column to map within the current instance. The height to map within the current instance. The width to map within the current instance. Thrown when either , or are negative or not within the bounds that are valid for the current instance. A new instance representing a slice of the current one. See additional remarks in the docs. Copies the contents of this into a destination instance. The destination instance. Thrown when is shorter than the source instance. Attempts to copy the current instance to a destination . The target of the copy operation. Whether or not the operation was successful. Copies the contents of this into a destination instance. For this API to succeed, the target has to have the same shape as the current one. The destination instance. Thrown when is shorter than the source instance. Attempts to copy the current instance to a destination . For this API to succeed, the target has to have the same shape as the current one. The target of the copy operation. Whether or not the operation was successful. Creates a handle for the memory. The GC will not move the memory until the returned is disposed, enabling taking and using the memory's address. An instance with non-primitive (non-blittable) members cannot be pinned. A instance wrapping the pinned handle. Tries to get a instance, if the underlying buffer is contiguous and small enough. The resulting , in case of success. Whether or not was correctly assigned. Copies the contents of the current instance into a new 2D array. A 2D array containing the data in the current instance. Defines an implicit conversion of an array to a A readonly version of . The type of items in the current instance. The target instance, if present. The initial byte offset within . The height of the specified 2D region. The width of the specified 2D region. The pitch of the specified 2D region. Initializes a new instance of the struct. The target to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Initializes a new instance of the struct. The target array to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target array to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Initializes a new instance of the struct wrapping a 2D array. The given 2D array to wrap. Initializes a new instance of the struct wrapping a 2D array. The given 2D array to wrap. The target row to map within . The target column to map within . The height to map within . The width to map within . Thrown when either , or are negative or not within the bounds that are valid for . Initializes a new instance of the struct wrapping a layer in a 3D array. The given 3D array to wrap. The target layer to map within . Thrown when a parameter is invalid. Initializes a new instance of the struct wrapping a layer in a 3D array. The given 3D array to wrap. The target layer to map within . The target row to map within . The target column to map within . The height to map within . The width to map within . Thrown when a parameter is invalid. Initializes a new instance of the struct. The target to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Initializes a new instance of the struct. The target to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Initializes a new instance of the struct with the specified parameters. The target instance. The initial offset within . The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map. Creates a new instance from an arbitrary object. The instance holding the data to map. The target reference to point to (it must be within ). The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map. A instance with the specified parameters. The parameter is not validated, and it's responsibility of the caller to ensure it's valid. Thrown when one of the input parameters is out of range. Gets an empty instance. Gets a value indicating whether the current instance is empty. Gets the length of the current instance. Gets the height of the underlying 2D memory area. Gets the width of the underlying 2D memory area. Gets a instance from the current memory. Slices the current instance with the specified parameters. The target range of rows to select. The target range of columns to select. Thrown when either or are invalid. A new instance representing a slice of the current one. Slices the current instance with the specified parameters. The target row to map within the current instance. The target column to map within the current instance. The height to map within the current instance. The width to map within the current instance. Thrown when either , or are negative or not within the bounds that are valid for the current instance. A new instance representing a slice of the current one. See additional remarks in the docs. Copies the contents of this into a destination instance. The destination instance. Thrown when is shorter than the source instance. Attempts to copy the current instance to a destination . The target of the copy operation. Whether or not the operation was successful. Copies the contents of this into a destination instance. For this API to succeed, the target has to have the same shape as the current one. The destination instance. Thrown when is shorter than the source instance. Attempts to copy the current instance to a destination . For this API to succeed, the target has to have the same shape as the current one. The target of the copy operation. Whether or not the operation was successful. Creates a handle for the memory. The GC will not move the memory until the returned is disposed, enabling taking and using the memory's address. An instance with non-primitive (non-blittable) members cannot be pinned. A instance wrapping the pinned handle. Tries to get a instance, if the underlying buffer is contiguous and small enough. The resulting , in case of success. Whether or not was correctly assigned. Copies the contents of the current instance into a new 2D array. A 2D array containing the data in the current instance. Defines an implicit conversion of an array to a Defines an implicit conversion of a to a A readonly version of . The type of items in the current instance. The instance pointing to the first item in the target memory area. The width of the specified 2D region. The stride of the specified 2D region. Initializes a new instance of the struct with the specified parameters. The reference to the first item to map. The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map (the distance between each row). Initializes a new instance of the struct with the specified parameters. The pointer to the first item to map. The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map (the distance between each row). Thrown when one of the parameters are negative. Initializes a new instance of the struct. The target array to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target array to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Initializes a new instance of the struct wrapping a 2D array. The given 2D array to wrap. Initializes a new instance of the struct wrapping a 2D array. The given 2D array to wrap. The target row to map within . The target column to map within . The height to map within . The width to map within . Thrown when either , or are negative or not within the bounds that are valid for . Initializes a new instance of the struct wrapping a layer in a 3D array. The given 3D array to wrap. The target layer to map within . Thrown when a parameter is invalid. Initializes a new instance of the struct wrapping a layer in a 3D array. The given 3D array to wrap. The target layer to map within . The target row to map within . The target column to map within . The height to map within . The width to map within . Thrown when a parameter is invalid. Initializes a new instance of the struct. The target to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Creates a new instance of the struct with the specified parameters. The reference to the first item to map. The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map (the distance between each row). A instance with the specified parameters. Thrown when one of the parameters are negative. Gets an empty instance. Gets a value indicating whether the current instance is empty. Gets the length of the current instance. Gets the height of the underlying 2D memory area. Gets the width of the underlying 2D memory area. Gets the element at the specified zero-based indices. The target row to get the element from. The target column to get the element from. A reference to the element at the specified indices. Thrown when either or are invalid. Gets the element at the specified zero-based indices. The target row to get the element from. The target column to get the element from. A reference to the element at the specified indices. Thrown when either or are invalid. Slices the current instance with the specified parameters. The target range of rows to select. The target range of columns to select. Thrown when either or are invalid. A new instance representing a slice of the current one. Copies the contents of this into a destination instance. The destination instance. Thrown when is shorter than the source instance. Copies the contents of this into a destination instance. For this API to succeed, the target has to have the same shape as the current one. The destination instance. Thrown when does not have the same shape as the source instance. Attempts to copy the current instance to a destination . The target of the copy operation. Whether or not the operation was successful. Attempts to copy the current instance to a destination . The target of the copy operation. Whether or not the operation was successful. Returns a reference to the 0th element of the instance. If the current instance is empty, returns a reference. It can be used for pinning and is required to support the use of span within a fixed statement. A reference to the 0th element, or a reference. Returns a reference to the first element within the current instance, with no bounds check. A reference to the first element within the current instance. Returns a reference to a specified element within the current instance, with no bounds check. The target row to get the element from. The target column to get the element from. A reference to the element at the specified indices. Slices the current instance with the specified parameters. The target row to map within the current instance. The target column to map within the current instance. The height to map within the current instance. The width to map within the current instance. Thrown when either , or are negative or not within the bounds that are valid for the current instance. A new instance representing a slice of the current one. See additional remarks in the docs. Gets a for a specified row. The index of the target row to retrieve. Throw when is out of range. The resulting row . Tries to get a instance, if the underlying buffer is contiguous and small enough. The resulting , in case of success. Whether or not was correctly assigned. Copies the contents of the current instance into a new 2D array. A 2D array containing the data in the current instance. Checks whether two instances are equal. The first instance to compare. The second instance to compare. Whether or not and are equal. Checks whether two instances are not equal. The first instance to compare. The second instance to compare. Whether or not and are not equal. Implicitly converts a given 2D array into a instance. The input 2D array to convert. Implicitly converts a given into a instance. The input to convert. Gets an enumerable that traverses items in a specified row. The target row to enumerate within the current instance. A with target items to enumerate. The returned value shouldn't be used directly: use this extension in a loop. Gets an enumerable that traverses items in a specified column. The target column to enumerate within the current instance. A with target items to enumerate. The returned value shouldn't be used directly: use this extension in a loop. Returns an enumerator for the current instance. An enumerator that can be used to traverse the items in the current instance Provides an enumerator for the elements of a instance. The instance pointing to the first item in the target memory area. Just like in , the length is the height of the 2D region. The width of the specified 2D region. The stride of the specified 2D region. The current horizontal offset. The current vertical offset. Initializes a new instance of the struct. The target instance to enumerate. Implements the duck-typed method. whether a new element is available, otherwise Gets the duck-typed property. represents a 2D region of arbitrary memory. Like the type, it can point to either managed or native memory, or to memory allocated on the stack. It is type- and memory-safe. One key difference with and arrays is that the underlying buffer for a instance might not be contiguous in memory: this is supported to enable mapping arbitrary 2D regions even if they require padding between boundaries of sequential rows. All this logic is handled internally by the type and it is transparent to the user, but note that working over discontiguous buffers has a performance impact. The type of items in the current instance. The instance pointing to the first item in the target memory area. The field maps to the height of the 2D region. This is done to save 4 bytes in the layout of the type. The width of the specified 2D region. The stride of the specified 2D region. This combines both the width and pitch in a single value so that the indexing logic can be simplified (no need to recompute the sum every time) and be faster. Initializes a new instance of the struct with the specified parameters. The reference to the first item to map. The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map (the distance between each row). Initializes a new instance of the struct with the specified parameters. The pointer to the first item to map. The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map (the distance between each row). Thrown when one of the parameters are negative. Initializes a new instance of the struct. The target array to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when doesn't match . Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target array to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when doesn't match . Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Initializes a new instance of the struct wrapping a 2D array. The given 2D array to wrap. Thrown when doesn't match . Initializes a new instance of the struct wrapping a 2D array. The given 2D array to wrap. The target row to map within . The target column to map within . The height to map within . The width to map within . Thrown when doesn't match . Thrown when either , or are negative or not within the bounds that are valid for . Initializes a new instance of the struct wrapping a layer in a 3D array. The given 3D array to wrap. The target layer to map within . Thrown when doesn't match . Thrown when a parameter is invalid. Initializes a new instance of the struct wrapping a layer in a 3D array. The given 3D array to wrap. The target layer to map within . The target row to map within . The target column to map within . The height to map within . The width to map within . Thrown when doesn't match . Thrown when a parameter is invalid. Initializes a new instance of the struct. The target to wrap. The height of the resulting 2D area. The width of each row in the resulting 2D area. Thrown when either or are invalid. The total area must match the length of . Initializes a new instance of the struct. The target to wrap. The initial offset within . The height of the resulting 2D area. The width of each row in the resulting 2D area. The pitch in the resulting 2D area. Thrown when one of the input parameters is out of range. Thrown when the requested area is outside of bounds for . Creates a new instance of the struct with the specified parameters. The reference to the first item to map. The height of the 2D memory area to map. The width of the 2D memory area to map. The pitch of the 2D memory area to map (the distance between each row). A instance with the specified parameters. Thrown when one of the parameters are negative. Gets an empty instance. Gets a value indicating whether the current instance is empty. Gets the length of the current instance. Gets the height of the underlying 2D memory area. Gets the width of the underlying 2D memory area. Gets the element at the specified zero-based indices. The target row to get the element from. The target column to get the element from. A reference to the element at the specified indices. Thrown when either or are invalid. Gets the element at the specified zero-based indices. The target row to get the element from. The target column to get the element from. A reference to the element at the specified indices. Thrown when either or are invalid. Slices the current instance with the specified parameters. The target range of rows to select. The target range of columns to select. Thrown when either or are invalid. A new instance representing a slice of the current one. Clears the contents of the current instance. Copies the contents of this into a destination instance. The destination instance. Thrown when is shorter than the source instance. Copies the contents of this into a destination instance. For this API to succeed, the target has to have the same shape as the current one. The destination instance. Thrown when does not have the same shape as the source instance. Attempts to copy the current instance to a destination . The target of the copy operation. Whether or not the operation was successful. Attempts to copy the current instance to a destination . The target of the copy operation. Whether or not the operation was successful. Fills the elements of this span with a specified value. The value to assign to each element of the instance. Returns a reference to the 0th element of the instance. If the current instance is empty, returns a reference. It can be used for pinning and is required to support the use of span within a fixed statement. A reference to the 0th element, or a reference. Returns a reference to the first element within the current instance, with no bounds check. A reference to the first element within the current instance. Returns a reference to a specified element within the current instance, with no bounds check. The target row to get the element from. The target column to get the element from. A reference to the element at the specified indices. Slices the current instance with the specified parameters. The target row to map within the current instance. The target column to map within the current instance. The height to map within the current instance. The width to map within the current instance. Thrown when either , or are negative or not within the bounds that are valid for the current instance. A new instance representing a slice of the current one. Contrary to , this method will throw an if attempting to perform a slice operation that would result in either axes being 0. That is, trying to call as eg. Slice(row: 1, column: 0, height: 0, width: 2) on an instance that has 1 row and 2 columns will throw, rather than returning a new instance with 0 rows and 2 columns. For contrast, trying to eg. call Slice(start: 1, length: 0) on a instance of length 1 would return a span of length 0, with the internal reference being set to right past the end of the memory. This is by design, and it is due to the internal memory layout that has. That is, in the case of , the only edge case scenario would be to obtain a new span of size 0, referencing the very end of the backing object (eg. an array or a instance). In that case, the GC can correctly track things. With , on the other hand, it would be possible to slice an instance with a sizeof 0 in either axis, but with the computed starting reference pointing well past the end of the internal memory area. Such a behavior would not be valid if the reference was pointing to a managed object, and it would cause memory corruptions (ie. "GC holes"). If you specifically need to be able to obtain empty values from slicing past the valid range, consider performing the range validation yourself (ie. through some helper method), and then only invoking once the parameters are in the accepted range. Otherwise, consider returning another return explicitly, such as . Gets a for a specified row. The index of the target row to retrieve. Throw when is out of range. The resulting row . Tries to get a instance, if the underlying buffer is contiguous and small enough. The resulting , in case of success. Whether or not was correctly assigned. Copies the contents of the current instance into a new 2D array. A 2D array containing the data in the current instance. Checks whether two instances are equal. The first instance to compare. The second instance to compare. Whether or not and are equal. Checks whether two instances are not equal. The first instance to compare. The second instance to compare. Whether or not and are not equal. Implicitly converts a given 2D array into a instance. The input 2D array to convert. Gets an enumerable that traverses items in a specified row. The target row to enumerate within the current instance. A with target items to enumerate. The returned value shouldn't be used directly: use this extension in a loop. Gets an enumerable that traverses items in a specified column. The target column to enumerate within the current instance. A with target items to enumerate. The returned value shouldn't be used directly: use this extension in a loop. Returns an enumerator for the current instance. An enumerator that can be used to traverse the items in the current instance Provides an enumerator for the elements of a instance. The instance pointing to the first item in the target memory area. Just like in , the length is the height of the 2D region. The width of the specified 2D region. The stride of the specified 2D region. The current horizontal offset. The current vertical offset. Initializes a new instance of the struct. The target instance to enumerate. Implements the duck-typed method. whether a new element is available, otherwise Gets the duck-typed property. A implementation wrapping an instance. The type of buffer writer to use. The target instance to use. Indicates whether or not the current instance has been disposed Initializes a new instance of the class. The target instance to use. A implementation wrapping an of instance. The type of source to use for the underlying data. The instance currently in use. Initializes a new instance of the class. The input instance to use. The instance currently in use. A factory class to produce instances. Creates a new from the input of instance. The input instance. Indicates whether or not can be written to. A wrapping the underlying data for . Thrown when has an invalid data store. Creates a new from the input of instance. The input instance. A wrapping the underlying data for . Thrown when has an invalid data store. Throws a when a given or instance has an unsupported backing store. Nothing, this method always throws. Gets a standard instance for a stream. A with the standard text. Throws a when trying to perform a not supported operation. Throws an when trying to write too many bytes to the target stream. Throws an when using an invalid seek mode. Nothing, as this method throws unconditionally. Throws an when setting the property. Throws an when an input buffer is . Throws an when the input count is negative. Throws an when the input count is negative. Throws an when the sum of offset and count exceeds the length of the target buffer. Throws an when using a disposed instance. Validates the argument (it needs to be in the [0, length]) range. The new value being set. The maximum length of the target . Validates the or arguments. The target array. The offset within . The number of elements to process within . Validates the property. Validates that a given instance hasn't been disposed. A implementation wrapping a or instance. The type of source to use for the underlying data. This type is not marked as so that it can be inherited by , which adds the support for the wrapped buffer. We're not worried about the performance penalty here caused by the JIT not being able to resolve the instruction, as this type is only exposed as a anyway, so the generated code would be the same. Indicates whether can be written to. The instance currently in use. The current position within . Indicates whether or not the current instance has been disposed Initializes a new instance of the class. The input instance to use. Indicates whether can be written to. An implementation wrapping an instance. The wrapped array. Initializes a new instance of the struct. The wrapped instance. An implementation wrapping an array. The wrapped array. The starting offset within . The usable length within . Initializes a new instance of the struct. The wrapped array. The starting offset within . The usable length within . Gets an empty instance. An implementation wrapping an instance. The wrapped array. Initializes a new instance of the struct. The wrapped instance. An interface for types acting as sources for instances. Gets the length of the underlying memory area. Gets a instance wrapping the underlying memory area. Gets a instance wrapping the underlying memory area. An implementation wrapping a of instance. The wrapped instance. The starting offset within . The usable length within . Initializes a new instance of the struct. The wrapped instance. The starting offset within . The usable length within . Used to indicate to the compiler that the .locals init flag should not be set in method headers.