|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractList
au.gov.tas.dpiwe.mr.util.MrAbstractList
au.gov.tas.dpiwe.mr.util.MrRandomList
public class MrRandomList
An concrete implementation of an AbstractList which can be shuffled and unshuffled. The shuffling only affects the order of iteration, which is guaranteed to be stable every time this list is of the same length. i.e. adding or removing elements will destabilize the iteration order, but restoring the length will result in the same slots being chosen in the same order once more.
| Field Summary | |
|---|---|
protected Random |
r
|
protected boolean |
shuffled
|
| Fields inherited from class au.gov.tas.dpiwe.mr.util.MrAbstractList |
|---|
l |
| Fields inherited from class java.util.AbstractList |
|---|
modCount |
| Constructor Summary | |
|---|---|
MrRandomList(List elements)
Creates a random list with a particular shuffled order. |
|
MrRandomList(List elements,
Random instance)
Creates a random list with a particular shuffled order resulting from the Random instance given. |
|
| Method Summary | |
|---|---|
Object |
clone()
|
Iterator |
iterator()
Returns the elements in a random order (if in shuffled state) or in natural order (if not in shuffled state). |
ListIterator |
listIterator()
Returns the elements in a random order (if in shuffled state) or in natural order (if not in shuffled state). |
static void |
main(String[] argv)
Run a quick little unit test. |
void |
reshuffle(long seed)
Reshuffles the list. |
void |
shuffle()
Puts the list in shuffled state (the default). |
void |
unshuffle()
Puts the list in unshuffled state. |
| Methods inherited from class au.gov.tas.dpiwe.mr.util.MrAbstractList |
|---|
add, get, remove, remove, set, size |
| Methods inherited from class java.util.AbstractList |
|---|
add, addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList |
| Methods inherited from class java.util.AbstractCollection |
|---|
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
|---|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray |
| Methods inherited from interface java.util.List |
|---|
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray |
| Field Detail |
|---|
protected Random r
protected boolean shuffled
| Constructor Detail |
|---|
public MrRandomList(List elements)
public MrRandomList(List elements,
Random instance)
elements - the list elements.instance - a source of randomness.| Method Detail |
|---|
public Iterator iterator()
iterator in interface Iterableiterator in interface Collectioniterator in interface Listiterator in class AbstractListpublic ListIterator listIterator()
listIterator in interface ListlistIterator in class AbstractListpublic void shuffle()
public void reshuffle(long seed)
seed - the new seed to shuffle with.public void unshuffle()
public Object clone()
throws CloneNotSupportedException
clone in class MrAbstractListCloneNotSupportedExceptionpublic static void main(String[] argv)
argv - no params needed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||