tinyscalautils.util
Members list
Type members
Classlikes
Fast (but not thread-safe) random number generator.
Fast (but not thread-safe) random number generator.
The implementation relies on SplittableRandom
. Java's fancier generators are not used.
The generator is always seeded. If an unseeded generator is needed, use the FastGenerator
object directly; it can be shared harmlessly throughout an application (including across threads).
Attributes
- Note
-
The generator returned by
self
is ''not'' thread-safe, even though it subclassesjava.util.Random
. - Companion
- object
- Source
- FastRandom.scala
- Supertypes
- Known subtypes
-
object FastRandom
A thread-safe, unseeded fast random number generator.
A thread-safe, unseeded fast random number generator.
The implementation relies on ThreadLocalRandom
, which can be shared across threads without contention. Java's fancier generators are not used.
This generator cannot be re-seeded (the setSeed
method throws UnsupportedOperationException
).
Attributes
- Companion
- class
- Source
- FastRandom.scala
- Supertypes
- Self type
-
FastRandom.type
Value members
Concrete methods
Calculates an average by ignoring a fixed number of low/high values. The number is specified as a number of ''pairs'' lowest/highest values.
Calculates an average by ignoring a fixed number of low/high values. The number is specified as a number of ''pairs'' lowest/highest values.
This function returns 0 if the sequence is empty, or all the numbers are ignored.
Attributes
- Source
- average.scala
The largest integer m
such that 2^m <= n
.
The largest integer m
such that 2^m <= n
.
Attributes
- Throws
-
IllegalArgumentException
if n is not positive.
- Source
- log2.scala
The largest integer m
such that 2^m <= n
.
The largest integer m
such that 2^m <= n
.
Attributes
- Throws
-
IllegalArgumentException
if n is not positive.
- Source
- log2.scala
Extensions
Extensions
Test that a number is zero.
Calculates the interger power of a number.
Calculates the interger power of a number.
Attributes
- Throws
-
IllegalArgumentException
if the power is negative.
- Since
-
1.5.0
- Note
-
This function does not check for overflows; it also return 1 when
m
is 0, even ifn
is zero. - Source
- pow.scala
Adds a Kotlin-like nextInt
method to random number generators. This method enables calls of the form rand.nextInt(1 to 100)
.
Adds a Kotlin-like nextInt
method to random number generators. This method enables calls of the form rand.nextInt(1 to 100)
.
This method is only defined for ranges. For a more general sequence of integers, use pickOne
instead.
Range argument cannot be empty.
Attributes
- Source
- randomRange.scala
A wrapper that calls all the Random
methods interruptibly. The new generator is as thread-safe as the original.
A wrapper that calls all the Random
methods interruptibly. The new generator is as thread-safe as the original.
Attributes
- Source
- FastRandom.scala