Class SortedListMemory<T>
java.lang.Object
de.monochromata.anaphors.cog.memory.SortedListMemory<T>
- Type Parameters:
T- The type of objects that the chunks in this memory can represents.
- All Implemented Interfaces:
Memory<T>,ModifiableMemory<T>
public class SortedListMemory<T> extends Object implements Memory<T>, ModifiableMemory<T>
TODO: The size of the list should be limited
- Since:
- 1.1.0
-
Constructor Summary
Constructors Modifier Constructor Description protectedSortedListMemory()Used in contract testing.SortedListMemory(ActivationFormula activationFormula)Create a sorted set memory that sorts values based on the activation at the time whengetChunks(long, int)is invoked.SortedListMemory(ActivationFormula activationFormula, LinkedHashSet<Chunk<T>> chunks) -
Method Summary
Modifier and Type Method Description voidadd(long timestamp, Chunk<T> chunk)voidaddAll(long timestamp, Collection<Chunk<T>> chunks)Collection<Chunk<T>>getChunks(long timestamp, int maximumCount)Returns a limited number of chunks from memory after sorting the chunks in descending order by activation.
-
Constructor Details
-
SortedListMemory
protected SortedListMemory()Used in contract testing. -
SortedListMemory
Create a sorted set memory that sorts values based on the activation at the time whengetChunks(long, int)is invoked. -
SortedListMemory
-
-
Method Details
-
add
- Specified by:
addin interfaceModifiableMemory<T>- Parameters:
timestamp- the point in time at which the addition occurs (in the format returned bySystem.currentTimeMillis()
-
addAll
- Specified by:
addAllin interfaceModifiableMemory<T>- Parameters:
timestamp- the point in time at which the addition occurs (in the format returned bySystem.currentTimeMillis()
-
getChunks
Description copied from interface:MemoryReturns a limited number of chunks from memory after sorting the chunks in descending order by activation.TODO: Maybe also add an accessor that limits by a maximum activation.
- Specified by:
getChunksin interfaceMemory<T>- Parameters:
timestamp- the point in time at which the access occurs (in the format returned bySystem.currentTimeMillis()maximumCount- The maximum number of chunks to return.- Returns:
- The collection containing up to
maximumCountchunks sorted, from highest to lowest activation.
-