Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add map methods #21

Merged
merged 2 commits into from
May 21, 2024
Merged

Add map methods #21

merged 2 commits into from
May 21, 2024

Conversation

HarrisonMc555
Copy link
Owner

Previously, the only way to create a new Array2D was to either manually specify both the source and size of the array or to provide preexisting rows/columns. However, it is common to want to create a new array from the contents of a previously existing array.

The new map_* methods allow the user to provide a "mapping" function that transforms the elements of the existing array into new elements for the new array.

There are "row major" and "column major" versions of these methods. The differences will not be relevant unless the provided "mapping" function is modifying shared state. See the test cases that modify a "counter" variable (mutable_counter).

There are several methods that can be used to create a new
`Array2D`. In the past, these have typically had the "source"
(iterator, generator function, etc.) first, followed by the
dimensions. However, this can make the source code somewhat awkward
if, for example, you use a closure the ends up being moderately
large. These functions now put the dimensions first, which makes the
"source" parameter last.
Previously, the only way to create a new `Array2D` was to either
manually specify both the source and size of the array or to provide
preexisting rows/columns. However, it is common to want to create a
new array from the contents of a previously existing array.

The new `map_*` methods allow the user to provide a "mapping" function
that transforms the elements of the existing array into new elements
for the new array.

There are "row major" and "column major" versions of these
methods. The differences will not be relevant unless the provided
"mapping" function is modifying shared state. See the test cases that
modify a "counter" variable (`mutable_counter`).
@HarrisonMc555 HarrisonMc555 merged commit 80acfc3 into master May 21, 2024
1 check passed
@HarrisonMc555 HarrisonMc555 deleted the map branch May 21, 2024 04:33
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.

1 participant