Skip to content

Add Memory3D<T> and Span3D<T>#1163

Open
Ethereal77 wants to merge 9 commits intoCommunityToolkit:mainfrom
Ethereal77:dev/memory3d
Open

Add Memory3D<T> and Span3D<T>#1163
Ethereal77 wants to merge 9 commits intoCommunityToolkit:mainfrom
Ethereal77:dev/memory3d

Conversation

@Ethereal77
Copy link

** Closes #723 **

This pull request adds four new types (Span3D<T> and Memory3D<T>, and their read-only counterparts) to allow working with 3D / volumetric data more confortably, as well as adding related extensions for arrays and spans to more easily interoperate with these new types and 3D indexing semantics.

  • Added Span3D<T>, ReadOnlySpan3D<T>, Memory3D<T>, and ReadOnlyMemory3D<T>.
  • Added AsSpan3D and AsMemory3D extension methods for T[,,] arrays.
  • Added AsMemory3D extension methods for Memory<T> and ReadOnlyMemory<T>.
  • Added AsSpan3D extension methods for Span<T> and ReadOnlySpan<T>.
  • Added GetRow, GetColumn, and GetDepthColumn extension methods for T[,,] arrays, and as part of the new types, allowing efficient enumeration of 3D array rows, columns, and depth columns via RefEnumerable<T> or ReadOnlyRefEnumerable<T>.
  • Introduced GetRowSpan and GetRowMemory methods to retrieve a Span<T> or Memory<T> over a specific row in a 3D array.

There are also new tests that covers every new type and functionality, mimicking as close as possible the tests already existing for the 2D methods/types already in the library.

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • Tested code with current supported SDKs
  • New component
    • Pull Request has been submitted to the documentation repository instructions. Link:
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

Currently, the PR builds succesfully, and tests pass. There is some things I would like to discuss prior to consider this complete:

  • Naming:
    • I have named the divisions of a volume along its depth dimension as "slices". I don't know if that is a good name. Some other names I've thought about were "layers", but that doesn't sound any better to me.
    • I have named a sequence of elements along the depth dimension a "depth column". Not very satisfied with that name either.
  • While creating the new types, I've encountered some inconsisntencies in Span2D regarding some XML docs. I presume that would need a new issue/PR.
  • I've tried to focus on just the wrapper span/memory types, and associated extensions to/from arrays/spans/memory. I've seen there is currently support for 2D spans in ParallelHelper. I presume this is out of scope, and matter for another PR too.
  • Regarding documentation:
    • Should I create the documentation PR mentioned in the checklist now? Can it be done later when naming is agreed upon and the PR is accepted?
    • The same question regarding the "project description for NuGet package".

* Span3D<T> and ReadOnlySpan3D<T>
* Ref-Enumerators for both
* Memory3D<T> and ReadOnlyMemory3D<T>
* They mimic the tests that already exist for Memory2D<T> and Span2D<T>
* To complement the new functionality of Memory3D<T> and Span3D<T>
* To be more in line with what the tests for 2D array extensions do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Span3D and ReadOnlySpan3D

1 participant

Comments