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
Features, 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 Features 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 TypeMethodDescriptionvoidAdds a named-feature to the store.Deep-copies the store, including duplicating each feature.The names of allFeatures in the store, in identical order to the store.features()AllFeatures 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()intsize()The total number ofFeatures in the store.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
NamedBeanthat contains it.
-
get
Gets a feature corresponding to a particular name.- Parameters:
name- the name of the feature.- Returns:
- the feature, encapsulated in the
NamedBeanthat contains it.
-
features
AllFeatures in the store, in identical order.- Returns:
- a newly-created list, that reuses the existing
Featureinstances.
-
featureNames
The names of allFeatures in the store, in identical order to the store.- Returns:
- a newly created
FeatureNameListcorresponding to the names of the features.
-
size
public int size()The total number ofFeatures in the store.- Returns:
- the total number.
-
iterator
- Specified by:
iteratorin interfaceIterable<T extends FeatureInput>
-
duplicate
Deep-copies the store, including duplicating each feature.- Returns:
- a deep-copy of the current instance.
-