public class Utils extends Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static <T> Stream<T> |
asStream(Iterator<T> iter)
Convert given iterator to a stream.
|
static <T> Stream<T> |
asStream(Iterator<T> iter,
long cnt)
Convert given iterator to a stream with known count of entries.
|
static <T> T |
copy(T orig)
Perform deep copy of an object.
|
static <T extends Serializable> |
deserialize(byte[] o)
Deserialized object represented as a byte array.
|
static int[] |
selectKDistinct(int n,
int k)
Select k distinct integers from range [0, n) with reservoir sampling:
https://en.wikipedia.org/wiki/Reservoir_sampling.
|
static int[] |
selectKDistinct(int n,
int k,
Random rand)
Select k distinct integers from range [0, n) with reservoir sampling:
https://en.wikipedia.org/wiki/Reservoir_sampling.
|
static <T extends Serializable> |
serialize(T o)
Serialized the specified object.
|
public static <T> T copy(T orig)
T
- Class of original object;orig
- Original object.public static int[] selectKDistinct(int n, int k, Random rand)
n
- Number specifying left end of range of integers to pick values from.k
- Count specifying how many integers should be picked.rand
- RNG.public static int[] selectKDistinct(int n, int k)
selectKDistinct(n, k, new Random())
.n
- Number specifying left end of range of integers to pick values from.k
- Count specifying how many integers should be picked.public static <T> Stream<T> asStream(Iterator<T> iter, long cnt)
T
- Type of entries.iter
- Iterator.cnt
- Count.public static <T> Stream<T> asStream(Iterator<T> iter)
T
- Iterator content type.iter
- Iterator.public static <T extends Serializable> byte[] serialize(T o)
o
- Object to be serialized.public static <T extends Serializable> T deserialize(byte[] o)
T
- Type of serialized object.o
- Serialized object.
GridGain In-Memory Computing Platform : ver. 8.9.15 Release Date : December 3 2024