org.planx.msd
Class Memory

java.lang.Object
  extended by org.planx.msd.Memory

public final class Memory
extends Object

Encapsulates the memory needed for an atomic discriminator. A Memory can only be used by one thread at a time, and it should be reused as much as possible, as it allocates a significant amount of memory. A good strategy, is to create one Memory per thread, and let all the discriminators of a particular thread use the Memory designated for that thread. This is done by passing the Memory object to the constructor of the discriminator. If only one thread is needed, use the getMemory method of DiscriminatorFactory.

Author:
Thomas Ambus

Field Summary
static int CAPACITY
          The size of the dictionary and used arrays.
 List[] dictionary
          A dictionary array of size CAPACITY for use during discrimination.
 int[] used
          An array of size CAPACITY to keep track of which indexes in dictionary is used.
 
Constructor Summary
Memory()
          Creates a new Memory that allocates a large amount of memory.
 
Method Summary
<U,S> Collection<List<S>>
discriminate(List<? extends U> values, IntExtractor<U,S> e)
          Convenience method to easily use the Memory's dictionary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CAPACITY

public static final int CAPACITY
The size of the dictionary and used arrays.

See Also:
Constant Field Values

dictionary

public final List[] dictionary
A dictionary array of size CAPACITY for use during discrimination. After each discrimination all entries in this array must be null.


used

public final int[] used
An array of size CAPACITY to keep track of which indexes in dictionary is used.

Constructor Detail

Memory

public Memory()
Creates a new Memory that allocates a large amount of memory.

Method Detail

discriminate

public <U,S> Collection<List<S>> discriminate(List<? extends U> values,
                                              IntExtractor<U,S> e)
Convenience method to easily use the Memory's dictionary.



Copyright © 2010. All Rights Reserved.