Skip to content

Populate Array with Constant Methods #119

Description

@ColmBhandal

Requirement

Add 1D and 2D Array Extension and one-based array methods for populating an array with a constant. Note: we can always just do a map and pass in a lambda for setting the constant value, then copy all the values from the mapped array to the source one. Or we could use Linq. But the point here is efficiency - the update of a constant value doesn't pose the same threat of some exception being thrown mid-way through as population with a lambda, so we should in this case update in place.

Clearly document that the update will happen in-place, and if an exception does somehow happen e.g. due to some threading issue, then the array will end up in a partly populated state - although it's not clear how a unit test could even be written for that.

Value Proposition

A fast update for initialisation of a constant value will allow arrays of constants other than the default value to be efficiently initialised.

Design Ideas

Use a for-loop - just like is done here: https://stackoverflow.com/a/1014015/5134722.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions