I have a list of integers (currently using cern.colt.list.IntArrayList). I can call "shuffle()" and randomly shuffle them. I would like to be able to reproduce a shuffle. I can reproduce a series of random numbers by setting a seed. I do not seem to be able to set a seed in this case. What should I do? I am open to other implementations.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
there is an alternative method which takes a Random as source
This is possible by using the shuffle method that allows you to provide the backing
Random
instance:Collections.shuffle(List<?> list, Random rnd)
:Example:
You can specify the Random instance with a seed value using public static void shuffle(List list, Random rnd). For the Random(long seed) constructor you can specify a seed.
From Java Docs: