Skip to content

More Array Tools#214

Open
HeroEyad wants to merge 1 commit into
NMVTeam:devfrom
HeroEyad:patch-7
Open

More Array Tools#214
HeroEyad wants to merge 1 commit into
NMVTeam:devfrom
HeroEyad:patch-7

Conversation

@HeroEyad

@HeroEyad HeroEyad commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

adds a handful of util functions to ArrayTools that the standard Array api doesn't cover. (or atleast that i know of)

what did i add?

  • shuffle: fisher yates in place shuffle
  • last: returns the last element or null if empty (instead of array[array.length - 1])
  • unique: removes the duplicate values in place
  • union: merges two arrays without any duplicates into a new array
  • swap: swaps two elements by index in place
  • groupBy : groups elements by a key function into a Map
  • chunk : splits an array into subarrays of a fixed size

please note

shuffle internally uses swap to avoid duplicating the swap logic. unique and shuffle change in place to stay consistent with the existing clear function. union returns a new array since there's no clear target to change into.

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