| JGL - The Generic Collection Library for Java |
All Packages Class Hierarchy This Package Previous Next Index
Class com.objectspace.jgl.algorithms.Shuffling
java.lang.Object
|
+----com.objectspace.jgl.algorithms.Shuffling
- public final class Shuffling
- extends Object
The Shuffling class contains generic shuffling algorithms.
- See Also:
- Shuffling examples
-
randomShuffle(BidirectionalIterator, BidirectionalIterator)
- Shuffle a sequence with uniform distribution by performing as many random swaps
as there are elements.
-
randomShuffle(BidirectionalIterator, BidirectionalIterator, Random)
- Shuffle a sequence with uniform distribution by performing as many random swaps
as there are elements.
-
randomShuffle(Container)
- Shuffle a random access container with uniform distribution by performing as many
random swaps as there are elements.
-
randomShuffle(Container, Random)
- Shuffle a random access container with uniform distribution by performing as many
random swaps as there are elements.
randomShuffle
public static void randomShuffle(BidirectionalIterator first,
BidirectionalIterator last,
Random rand)
- Shuffle a sequence with uniform distribution by performing as many random swaps
as there are elements. Time complexity is linear and space complexity is constant.
- Parameters:
- first - An iterator positioned at the first element of the sequence.
- last - An iterator positioned immediately after the last element of the sequence.
- rand - An instance of java.util.Random to use when calculating which elements to swap.
- Throws: IllegalArgumentException
- If the iterators are incompatible
or if the containers upon which the iteratore operate is not a com.objectspace.jgl.Sequence.
randomShuffle
public static void randomShuffle(BidirectionalIterator first,
BidirectionalIterator last)
- Shuffle a sequence with uniform distribution by performing as many random swaps
as there are elements. Time complexity is linear and space complexity is constant.
- Parameters:
- first - An iterator positioned at the first element of the sequence.
- last - An iterator positioned immediately after the last element of the sequence.
- Throws: IllegalArgumentException
- If the iterators are incompatible.
randomShuffle
public static void randomShuffle(Container container,
Random rand)
- Shuffle a random access container with uniform distribution by performing as many
random swaps as there are elements. Time complexity is linear and space complexity
is constant.
- Parameters:
- container - The container.
- rand - An instance of java.util.Random to use when calculating which elements to swap.
randomShuffle
public static void randomShuffle(Container container)
- Shuffle a random access container with uniform distribution by performing as many
random swaps as there are elements. Time complexity is linear and space complexity
is constant.
- Parameters:
- container - The container.
All Packages Class Hierarchy This Package Previous Next Index