LimeWire Collection Component API

org.limewire.collection
Class RandomSequence

java.lang.Object
  extended by org.limewire.collection.RandomSequence
All Implemented Interfaces:
Iterable<Integer>

public class RandomSequence
extends Object
implements Iterable<Integer>

Generates all the integers from 0 to a certain limit in a random fashion where each number is generated only once per cycle.

RandomSequence also implements the Iterable interface that iterates over a single cycle.

For more information regarding the logic, see Linear congruential generator.

Thanks to Cyclonus for the pow2 hint.

    for(Integer o : new RandomSequence(10))
        System.out.println(o);

    Random Output:
        4
        7
        2
        5
        0
        3
        1
        8
        6
        9


Constructor Summary
RandomSequence(int end)
           
 
Method Summary
 Iterator<Integer> iterator()
           
 int nextInt()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomSequence

public RandomSequence(int end)
Method Detail

nextInt

public int nextInt()

iterator

public Iterator<Integer> iterator()
Specified by:
iterator in interface Iterable<Integer>

LimeWire Collection Component API

Copyright © 2008 Lime Wire LLC. All Rights Reserved.