Class FeatureList<T extends FeatureInput>
- Type Parameters:
T- input type of features contained in the list
public class FeatureList<T extends FeatureInput>
extends AnchorBean<FeatureList<T>>
implements Iterable<Feature<T>>
A list of features with the same input-type.
- Author:
- Owen Feehan
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates with an empty list.FeatureList(int capacity) Creates with an empty list of particular capacity.FeatureList(List<Feature<T>> list) Wraps an existing list.FeatureList(Stream<Feature<T>> stream) Creates from a stream ofFeatures.FeatureList(Feature<T> feature) Creates with a singleFeature. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a feature to the current list.voidaddAll(FeatureList<? extends T> toAdd) Add all the features inotherto the current list.append(Optional<FeatureList<T>> featureList) Appends the features one or more (optional) feature-lists to the existing list.asList()Exposes the underlying list of features in this data-structure.voidclear()Removes all of the elements from this list.Derives the names of the features.<S extends FeatureInput, E extends Exception>
FeatureList<S> filterAndMap(Predicate<Feature<T>> predicate, CheckedFunction<Feature<T>, Feature<S>, E> mappingFunction) get(int index) Returns the element at the specified position in this list.getList()The list of features.voidinitializeRecursive(FeatureInitialization initialization, Logger logger) Initializes all features in the list, and recursively any features they contain.booleanisEmpty()Returnstrueif this list contains no elements.iterator()<S extends FeatureInput, E extends Exception>
FeatureList<S> map(CheckedFunction<Feature<T>, Feature<S>, E> mapFunc) Creates a new feature-list where each feature is the result of applying a map-function to an existing feature.voidThe list of features.Creates a new feature-list which contains identical elements.intsize()Returns the number of elements in this list.sort(Comparator<Feature<T>> comparator) Creates a new feature-list sorted in a particular order.Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
FeatureList
public FeatureList()Creates with an empty list. -
FeatureList
public FeatureList(int capacity) Creates with an empty list of particular capacity.- Parameters:
capacity- initial capacity of the created empty list.
-
FeatureList
-
FeatureList
-
FeatureList
-
-
Method Details
-
initializeRecursive
public void initializeRecursive(FeatureInitialization initialization, Logger logger) throws InitializeException Initializes all features in the list, and recursively any features they contain.A feature must be initialized before being used for calculation.
- Parameters:
initialization- the initialization parameters.logger- the logger.- Throws:
InitializeException- if any feature cannot be successfully initialized.
-
map
public <S extends FeatureInput, E extends Exception> FeatureList<S> map(CheckedFunction<Feature<T>, Feature<S>, E> mapFunc) throws E Creates a new feature-list where each feature is the result of applying a map-function to an existing feature.- Type Parameters:
S- input-type of feature to be created as result of mappingE- exception that can be thrown during mapping- Parameters:
mapFunc- function to perform the mapping of each item.- Returns:
- a newly created feature-list (with the same number of items) containing the mapped features.
- Throws:
E- if the mapping-function throws this exception.
-
filterAndMap
public <S extends FeatureInput, E extends Exception> FeatureList<S> filterAndMap(Predicate<Feature<T>> predicate, CheckedFunction<Feature<T>, Feature<S>, E> mappingFunction) throws E Filters inputs and then performs amap(org.anchoranalysis.core.functional.checked.CheckedFunction<org.anchoranalysis.feature.bean.Feature<T>, org.anchoranalysis.feature.bean.Feature<S>, E>).This is an immutable operation.
- Type Parameters:
S- input-type of feature to be created as result of mappingE- exception that can be thrown during mapping- Parameters:
predicate- iff true object is included, otherwise excluded.mappingFunction- the function that performs the mapping.- Returns:
- a newly created feature-list, a filtered version of all features, then mapped.
- Throws:
E- if the mapping-function throws this exception.
-
append
Appends the features one or more (optional) feature-lists to the existing list.This is an immutable operation and the existing list is not altered.
- Parameters:
featureList- the optional feature-lists to append.- Returns:
- a newly-created list with all the existing features, as well as any optional additional features.
-
deriveNames
-
sort
Creates a new feature-list sorted in a particular order.- Parameters:
comparator- used to determine the order of elements when sorting.- Returns:
- a newly-created list with the same elements in sorted order.
-
shallowDuplicate
Creates a new feature-list which contains identical elements.- Returns:
- a newly-created list with the same elements in the same order.
-
add
-
isEmpty
public boolean isEmpty()Returnstrueif this list contains no elements.- Returns:
trueif this list contains no elements.
-
iterator
-
size
public int size()Returns the number of elements in this list.- Returns:
- the number of elements in this list.
-
asList
-
describeBean
- Overrides:
describeBeanin classAnchorBean<FeatureList<T extends FeatureInput>>
-
get
-
clear
public void clear()Removes all of the elements from this list.The list will be empty after this call returns.
-
addAll
Add all the features inotherto the current list.- Parameters:
toAdd- the features to add.
-
getList
-
setList
-