+
+
+
+ Struct IndexPool
+ Represents a pool of integer values.
+
+
+
+
Implements
+
+
+
+
+
+
+
+
+
+
Inherited Members
+
+
+
+
+
+
+
+
+ Assembly: DotNext.Threading.dll
+ Syntax
+
+
public struct IndexPool : ISupplier<int>, IFunctional<Func<int>>, IConsumer<int>, IFunctional<Action<int>>, IReadOnlyCollection<int>, IEnumerable<int>, IEnumerable
+
+
+
+ Constructors
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ IndexPool()
+ Initializes a new pool that can return an integer value within the range [0..MaxValue].
+
+
+ Declaration
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ IndexPool(int)
+ Initializes a new pool that can return an integer within the range [0..maxValue
].
+
+
+ Declaration
+
+
public IndexPool(int maxValue)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ int |
+ maxValue |
+ The maximum possible value to return, inclusive.
+ |
+
+
+
+ Exceptions
+
+ Properties
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ Capacity
+ Gets the maximum capacity of the pool.
+
+
+ Declaration
+
+
public static int Capacity { get; }
+
+ Property Value
+
+
+
+ Type |
+ Description |
+
+
+
+
+ int |
+ |
+
+
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ Count
+ Gets the number of available indicies.
+
+
+ Declaration
+
+
public readonly int Count { get; }
+
+ Property Value
+
+
+
+ Type |
+ Description |
+
+
+
+
+ int |
+ |
+
+
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ MaxValue
+ Gets the maximum number that can be returned by the pool.
+
+
+ Declaration
+
+
public static int MaxValue { get; }
+
+ Property Value
+
+
+
+ Type |
+ Description |
+
+
+
+
+ int |
+ Always returns 63 .
+ |
+
+
+
+ Methods
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ Contains(int)
+ Determines whether the specified index is available for rent.
+
+
+ Declaration
+
+
public readonly bool Contains(int value)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ int |
+ value |
+ The value to check.
+ |
+
+
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ bool |
+ true if value is available for rent; otherwise, false.
+ |
+
+
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ GetEnumerator()
+ Gets an enumerator over available indicies in the pool.
+
+
+ Declaration
+
+
public readonly IndexPool.Enumerator GetEnumerator()
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ IndexPool.Enumerator |
+ The enumerator over available indicies in this pool.
+ |
+
+
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ Return(int)
+
+
+ Declaration
+
+
public void Return(int value)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ int |
+ value |
+ |
+
+
+
+ Exceptions
+
+
+
+ Type |
+ Condition |
+
+
+
+
+ ArgumentOutOfRangeException |
+ value is less than zero or greater than the maximum
+value specified for this pool.
+ |
+
+
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ Return(ReadOnlySpan<int>)
+ Returns multiple indicies, atomically.
+
+
+ Declaration
+
+
public void Return(ReadOnlySpan<int> indicies)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ ReadOnlySpan<int> |
+ indicies |
+ The buffer of indicies to return back to the pool.
+ |
+
+
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ Take()
+ Returns the available index from the pool.
+
+
+ Declaration
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ int |
+ The index which is greater than or equal to zero.
+ |
+
+
+
+ Exceptions
+
+
+
+ Type |
+ Condition |
+
+
+
+
+ OverflowException |
+ There is no available index to return.
+ |
+
+
+
+ See Also
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ Take(Span<int>)
+ Takes all available indicies, atomically.
+
+
+ Declaration
+
+
public int Take(Span<int> indicies)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ Span<int> |
+ indicies |
+ The buffer to be modified with the indicies taken from the pool.
+The size of the buffer should not be less than Capacity.
+ |
+
+
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ int |
+ The number of indicies written to the buffer.
+ |
+
+
+
+ Exceptions
+
+ See Also
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ TryPeek(out int)
+ Tries to peek the next available index from the pool, without acquiring it.
+
+
+ Declaration
+
+
public readonly bool TryPeek(out int result)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ int |
+ result |
+ The index which is greater than or equal to zero.
+ |
+
+
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ bool |
+ true if the index is available for rent; otherwise, false.
+ |
+
+
+
+
+ |
+ Edit this page
+
+
+ View Source
+
+
+ TryTake(out int)
+ Returns the available index from the pool.
+
+
+ Declaration
+
+
public bool TryTake(out int result)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ int |
+ result |
+ The index which is greater than or equal to zero.
+ |
+
+
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ bool |
+ true if the index is successfully rented from the pool; otherwise, false.
+ |
+
+
+
+ See Also
+
+ Implements
+
+
+
+
+
+
+
+ Extension Methods
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+