Package org.anchoranalysis.feature.store
Class NamedFeatureStore<T extends FeatureInput>
Object
NamedFeatureStore<T>
- Type Parameters:
T
- the feature-input type for all features in the store.
public class NamedFeatureStore<T extends FeatureInput>
extends Object
implements Iterable<NamedBean<Feature<T>>>
Stores
Feature
s, each with an associated name, with list-like access and map-like access.
Each feature is stored in an ordered manner, and zero-indexed.
A map between the name of each feature, and the feature's index position is simultaneously maintained.
If the names of two or more Feature
s are identical, only a single Feature
will
be retrieved by name. The list-access remains unaffected.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a named-feature to the store.Deep-copies the store, including duplicating each feature.The names of allFeature
s in the store, in identical order to the store.features()
AllFeature
s in the store, in identical order.get
(int index) Gets a feature at a particular position.Gets a feature corresponding to a particular name.iterator()
int
size()
The total number ofFeature
s in the store.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
NamedFeatureStore
public NamedFeatureStore()
-
-
Method Details
-
add
Adds a named-feature to the store. The customName() of the feature is replaced with the name.- Parameters:
name
- name of the feature.feature
- the feature to add (whose customName will be overridden with the name).
-
get
Gets a feature at a particular position.- Parameters:
index
- the position to retrieve (zero-indexed).- Returns:
- the feature, encapsulated in the
NamedBean
that contains it.
-
get
Gets a feature corresponding to a particular name.- Parameters:
name
- the name of the feature.- Returns:
- the feature, encapsulated in the
NamedBean
that contains it.
-
features
AllFeature
s in the store, in identical order.- Returns:
- a newly-created list, that reuses the existing
Feature
instances.
-
featureNames
The names of allFeature
s in the store, in identical order to the store.- Returns:
- a newly created
FeatureNameList
corresponding to the names of the features.
-
size
public int size()The total number ofFeature
s in the store.- Returns:
- the total number.
-
iterator
- Specified by:
iterator
in interfaceIterable<T extends FeatureInput>
-
duplicate
Deep-copies the store, including duplicating each feature.- Returns:
- a deep-copy of the current instance.
-