|
|
|
@@ -30,9 +30,11 @@ namespace LLama.Common |
|
|
|
/// <param name="data"></param> |
|
|
|
public FixedSizeQueue(int size, IEnumerable<T> data) |
|
|
|
{ |
|
|
|
#if NETCOREAPP3_0_OR_GREATER |
|
|
|
// Try an early check on the amount of data supplied (if possible) |
|
|
|
if (data.TryGetNonEnumeratedCount(out var count) && count > size) |
|
|
|
throw new ArgumentException($"The max size set for the quene is {size}, but got {count} initial values."); |
|
|
|
#endif |
|
|
|
|
|
|
|
// Size of "data" is unknown, copy it all into a list |
|
|
|
_maxSize = size; |
|
|
|
@@ -40,7 +42,7 @@ namespace LLama.Common |
|
|
|
|
|
|
|
// Now check if that list is a valid size |
|
|
|
if (_storage.Count > _maxSize) |
|
|
|
throw new ArgumentException($"The max size set for the quene is {size}, but got {count} initial values."); |
|
|
|
throw new ArgumentException($"The max size set for the quene is {size}, but got {_storage.Count} initial values."); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|