LimeWire collection component api

org.limewire.collection
Class RandomSequence

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

public class RandomSequence
extends java.lang.Object
implements java.lang.Iterable<java.lang.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
 java.util.Iterator<java.lang.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 java.util.Iterator<java.lang.Integer> iterator()
Specified by:
iterator in interface java.lang.Iterable<java.lang.Integer>

LimeWire collection component api

Copyright © 2009 Lime Wire LLC. All Rights Reserved.