Skip to content

Commit

Permalink
Merge pull request #1 from AnnulusGames/fix-iweightedcollection-def
Browse files Browse the repository at this point in the history
Fix: the definition of IWeightedCollection<T>
  • Loading branch information
AnnulusGames authored Aug 19, 2024
2 parents a59b6b8 + 485c72e commit 0a125af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/RandomExtensions/Collections/IWeightedCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace RandomExtensions.Collections;

public interface IWeightedCollection<T> : IReadOnlyCollection<WeightedValue<T>>
{
T GetItem<TRandom>(TRandom random) where TRandom : IRandom;
void GetItems<TRandom>(TRandom random, Span<T> destination) where TRandom : IRandom;
T GetItem(IRandom random);
void GetItems(IRandom random, Span<T> destination);
}
6 changes: 2 additions & 4 deletions src/RandomExtensions/Collections/WeightedList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ public Enumerator GetEnumerator()
return new Enumerator(this);
}

public T GetItem<TRandom>(TRandom random)
where TRandom : IRandom
public T GetItem(IRandom random)
{
var r = random.NextDouble() * totalWeight;
var current = 0.0;
Expand All @@ -142,8 +141,7 @@ public T GetItem<TRandom>(TRandom random)
return default!;
}

public void GetItems<TRandom>(TRandom random, Span<T> destination)
where TRandom : IRandom
public void GetItems(IRandom random, Span<T> destination)
{
for (int i = 0; i < destination.Length; i++)
{
Expand Down

0 comments on commit 0a125af

Please sign in to comment.