Skip to content

Commit

Permalink
Fix: the definition of IWeightedCollection<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnulusGames committed Aug 19, 2024
1 parent a59b6b8 commit 485c72e
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 485c72e

Please sign in to comment.