Package com.oracle.coherence.common.base
Class Randoms
java.lang.Object
com.oracle.coherence.common.base.Randoms
Class for providing random functionality.
- Since:
- 20.06
- Author:
- cp 2000.08.02
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Return a random number assigned to this process.static Random
Obtain a Random object that can be used to get random values.static Binary
getRandomBinary
(int cbMin, int cbMax) Generates a random-length Binary within the length bounds provided whose contents are random bytes.static Binary
getRandomBinary
(int cbMin, int cbMax, byte... abHead) Generates a random-length Binary includingabHead
at the head of the Binary, in addition to random bytes within the length bounds provided.static String
getRandomString
(int cchMin, int cchMax, boolean fAscii) Generates a random-length String within the length bounds provided.static int[]
randomize
(int[] a) Randomize the order of the elements within the passed array.static long[]
randomize
(long[] a) Randomize the order of the elements within the passed array.static Object[]
Randomize the order of the elements within the passed array.static List
randomize
(Collection coll) Randomize the order of the elements within the passed collection.
-
Constructor Details
-
Randoms
public Randoms()
-
-
Method Details
-
getProcessRandom
public static int getProcessRandom()Return a random number assigned to this process.This value will remain the same across invocations, but is generally different across JVMs.
- Returns:
- the process's random number.
-
getRandom
Obtain a Random object that can be used to get random values.- Returns:
- a random number generator
- Since:
- Coherence 3.2
-
randomize
Randomize the order of the elements within the passed collection.- Parameters:
coll
- the Collection to randomize; the passed Collection is not altered- Returns:
- a new and immutable List whose contents are identical to those of the passed collection except for the order in which they appear
- Since:
- Coherence 3.2
-
randomize
Randomize the order of the elements within the passed array.- Parameters:
a
- an array of objects to randomize- Returns:
- the array that was passed in, and with its contents unchanged except for the order in which they appear
- Since:
- Coherence 3.2
-
randomize
public static int[] randomize(int[] a) Randomize the order of the elements within the passed array.- Parameters:
a
- an array of int values to randomize- Returns:
- the array that was passed in, and with its contents unchanged except for the order in which they appear
- Since:
- Coherence 3.2
-
randomize
public static long[] randomize(long[] a) Randomize the order of the elements within the passed array.- Parameters:
a
- an array of long values to randomize- Returns:
- the array that was passed in, and with its contents unchanged except for the order in which they appear
- Since:
- Coherence 12.2.1.4
-
getRandomBinary
Generates a random-length Binary within the length bounds provided whose contents are random bytes.- Parameters:
cbMin
- the minimum number of bytes in the resulting BinarycbMax
- the maximum number of bytes in the resulting Binary- Returns:
- a randomly generated Binary object
- Since:
- Coherence 3.2
-
getRandomBinary
Generates a random-length Binary includingabHead
at the head of the Binary, in addition to random bytes within the length bounds provided.- Parameters:
cbMin
- the minimum number of bytes in the resulting BinarycbMax
- the maximum number of bytes in the resulting BinaryabHead
- the head of the returned Binary- Returns:
- a randomly generated Binary object with a length of
[len(abHead) + cbMin, cbMax]
- Since:
- Coherence 12.1.3
-
getRandomString
Generates a random-length String within the length bounds provided. If the ASCII option is indicated, the characters will be in the range [32-127], otherwise the characters will be in the range [0x0000-0xFFFF].- Parameters:
cchMin
- the minimum length of the resulting StringcchMax
- the maximum length of the resulting StringfAscii
- true if the resulting String should contain only ASCII values- Returns:
- a randomly generated String object
- Since:
- Coherence 3.2
-