RobustToolbox icon indicating copy to clipboard operation
RobustToolbox copied to clipboard

Feature/refine robust random and cleanup

Open Fildrance opened this issue 1 year ago • 1 comments
trafficstars

Refined xml-doc for IRobustRandom Changed RobustRandom namespace to be file-scoped Added new methods to RandomExtensions for getting list of random items from collections:

    IReadOnlyCollection<T> GetItems<T>(this IRobustRandom random, IList<T> collection, int count, bool allowDuplicates = true);

    ValueList<T> GetItems<T>(this IRobustRandom random, ValueList<T> collection, int count, bool allowDuplicates = true);

    Span<T> GetItems<T>(this IRobustRandom random, Span<T> collection, int count, bool allowDuplicates = true);

Main scenarios for new methods:

  • Need to pick item random from list of items
  • Need to pick several random items from list, only unique
  • Need to pick items from list several times, duplicates allowed.

Separated refactoring and adding code into separate commits for comfortable code-review.

Fildrance avatar Mar 17 '24 18:03 Fildrance

@ElectroJr can u pls close comments if they are fixed correctly?

Fildrance avatar Mar 20 '24 15:03 Fildrance

Just bulldoze https://github.com/space-wizards/RobustToolbox/pull/4980

I woulda merged yours first but wasn't sure on some changes.

metalgearsloth avatar Mar 24 '24 02:03 metalgearsloth

Needs release notes.

Done (question mark)

Fildrance avatar Mar 24 '24 09:03 Fildrance

Just bulldoze #4980

I woulda merged yours first but wasn't sure on some changes.

merged as well as i could

Fildrance avatar Mar 24 '24 09:03 Fildrance