public class CogxelStateLite extends AbstractCloneableSerializable implements CogxelState
Constructor and Description |
---|
CogxelStateLite()
Creates a new instance of CogxelStateLite
|
CogxelStateLite(CogxelState other)
Creates a copy of a CogxelStateLite
|
CogxelStateLite(int initialCapacity)
Creates a new instance of CogxelStateLite with an expected initial
capacity for the number of cogxels contained in it.
|
Modifier and Type | Method and Description |
---|---|
void |
addCogxel(Cogxel cogxel)
Adds a Cogxel to the state, overriding the existing Cogxel, if it
exists.
|
void |
clear()
Clears all of the Cogxels in this CogxelState.
|
CogxelStateLite |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
Cogxel |
getCogxel(SemanticIdentifier identifier)
Gets a Cogxel from the state, if it has been previously added.
|
double |
getCogxelActivation(SemanticIdentifier identifier)
Gets the activation level of a Cogxel in the CogxelState.
|
java.util.Collection<Cogxel> |
getCogxels()
Gets the Cogxels that have been previously added to this CogxelState.
|
int |
getNumCogxels()
Gets the number of existing Cogxels in this CogxelState.
|
Cogxel |
getOrCreateCogxel(SemanticIdentifier identifier,
CogxelFactory factory)
Attempts to get an existing Cogxel for a given SemanticIdentifier.
|
boolean |
hasCogxel(SemanticIdentifier identifier)
Returns true if there is an existing Cogxel for the given identifier and
false otherwise.
|
java.util.Iterator<Cogxel> |
iterator() |
boolean |
removeCogxel(Cogxel cogxel)
Removes a Cogxel from the CogxelState, if it exists.
|
boolean |
removeCogxel(SemanticIdentifier identifier)
Removes a Cogxel from the state, if it exists.
|
public CogxelStateLite()
public CogxelStateLite(int initialCapacity)
initialCapacity
- The initial maximum capacity, as defined as the
maximum SemanticIdentifier expected.public CogxelStateLite(CogxelState other)
other
- The CogxelState to copy.public CogxelStateLite clone()
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CogxelState
clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public void clear()
public void addCogxel(Cogxel cogxel)
addCogxel
in interface CogxelState
cogxel
- The Cogxel to add.java.lang.IllegalArgumentException
- If an invalid Cogxel is given.public boolean hasCogxel(SemanticIdentifier identifier)
hasCogxel
in interface CogxelState
identifier
- The identifier to look for the Cogxel.public Cogxel getCogxel(SemanticIdentifier identifier)
getCogxel
in interface CogxelState
identifier
- The SemanticIdentifier for the Cogxel.java.lang.IllegalArgumentException
- If an invalid identifier is given.public Cogxel getOrCreateCogxel(SemanticIdentifier identifier, CogxelFactory factory)
getOrCreateCogxel
in interface CogxelState
identifier
- The identifier to get or create a Cogxel for.factory
- The factory to use to create the Cogxel is one does not
already exist for the identifier.java.lang.IllegalArgumentException
- If an invalid identifier is given.public boolean removeCogxel(SemanticIdentifier identifier)
removeCogxel
in interface CogxelState
identifier
- The SemanticIdentifier of the Cogxel to remove.java.lang.IllegalArgumentException
- If an invalid identifier is given.public boolean removeCogxel(Cogxel cogxel)
removeCogxel
in interface CogxelState
cogxel
- The Cogxel to remove.java.lang.IllegalArgumentException
- If an invalid Cogxel is given.public double getCogxelActivation(SemanticIdentifier identifier)
getCogxelActivation
in interface CogxelState
identifier
- The SemanticIdentifier for the Cogxel to get the
activation level of.java.lang.IllegalArgumentException
- If an invalid identifier is given.public java.util.Collection<Cogxel> getCogxels()
getCogxels
in interface CogxelState
public int getNumCogxels()
getNumCogxels
in interface CogxelState