nars.storage
Class Distributor

java.lang.Object
  extended by nars.storage.Distributor

 class Distributor
extends java.lang.Object

A pseudo-random number generator, used in Bag.


Field Summary
private  int capacity
          Capacity of the array
private  int[] order
          Shuffled sequence of index numbers
 
Constructor Summary
Distributor(int range)
          For any number N < range, there is N+1 copies of it in the array, distributed as evenly as possible
 
Method Summary
 int next(int index)
          Advance the index
 int pick(int index)
          Get the next number according to the given index
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

order

private int[] order
Shuffled sequence of index numbers


capacity

private int capacity
Capacity of the array

Constructor Detail

Distributor

public Distributor(int range)
For any number N < range, there is N+1 copies of it in the array, distributed as evenly as possible

Parameters:
range - Range of valid numbers
Method Detail

pick

public int pick(int index)
Get the next number according to the given index

Parameters:
index - The current index
Returns:
the random value

next

public int next(int index)
Advance the index

Parameters:
index - The current index
Returns:
the next index