public abstract class AbstractPolicy extends java.lang.Object implements Policy
Modifier and Type | Field and Description |
---|---|
(package private) static int |
DEFAULT_SAMPLE_SIZE
The sample size to use
|
(package private) static java.util.Random |
RANDOM
Used to select random numbers
|
Constructor and Description |
---|
AbstractPolicy() |
Modifier and Type | Method and Description |
---|---|
static int |
calculateSampleSize(int populationSize)
sampleSize how many samples to take
|
static int[] |
generateRandomSample(int populationSize)
Generates a random sample from a population
|
Element |
selectedBasedOnPolicy(Element[] sampledElements,
Element justAdded)
Finds the best eviction candidate based on the sampled elements.
|
static final int DEFAULT_SAMPLE_SIZE
static final java.util.Random RANDOM
public static int calculateSampleSize(int populationSize)
populationSize
- the size of the storepublic Element selectedBasedOnPolicy(Element[] sampledElements, Element justAdded)
selectedBasedOnPolicy
in interface Policy
sampledElements
- this should be a random subset of the populationjustAdded
- we never want to select the element just added. May be null.public static int[] generateRandomSample(int populationSize)
populationSize
- the size to draw from