Utils
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| Empty | 1 | Creates an empty array |
| Range | 1 | Creates an array filled with index values |
| Filled | 1 | Creates an array filled with a specific value |
| RejectionSample | 1 | Generate nSamples many integers from 0 to poolSize such that no integer is selected twice.The duplication constraint is achieved via rejection sampling. |
| ShuffleSample | 1 | partial Fisher-Yates shuffle of the index pool 0, poolSize) for the degenerate case of [Utils.RejectionSample()) |
| NewStripedLocks | 1 | Create a striped lock object array. |
03 Members
Int32)Creates an empty array
Int32)Creates an array filled with index values
Int32, Double)Creates an array filled with a specific value
Int32, Int32, IProvideRandomValues)Generate nSamples many integers from 0 to poolSize such that no integer is selected twice.The duplication constraint is achieved via rejection sampling.
the deduplication check of this function is implemented based on a HashSet object instead of the original O(n^2) linear scan, so that the sampling procedure is O(n) now.
note about that the number of the random numbers that have been consumed by this function is not changed, so the generated result is still the same as the original implementation for a given random source.
Int32(), Int32, IProvideRandomValues)partial Fisher-Yates shuffle of the index pool 0, poolSize) for the degenerate case of [Utils.RejectionSample()
Int32)Create a striped lock object array.
the striped lock is used for protect the heap row while running the heap push operation in parallel. the lock objects are always acquired in the ascending order of the stripe index, so that the dead lock is impossible.
| Name | Type | Description |
|---|---|---|
stripes | Int32 | the number of the lock objects, a larger value means a lower lock contention but a higher memory footprint. |
a lock array that is indexed via row Mod length.