Class ExtremumOperator<T extends java.lang.Comparable<T>>
- java.lang.Object
-
- org.eclipse.viatra.query.runtime.matchers.aggregators.ExtremumOperator<T>
-
- All Implemented Interfaces:
IMultisetAggregationOperator<T,java.util.SortedMap<T,java.lang.Integer>,T>
public class ExtremumOperator<T extends java.lang.Comparable<T>> extends java.lang.Object implements IMultisetAggregationOperator<T,java.util.SortedMap<T,java.lang.Integer>,T>
Incrementally computes the minimum or maximum of java.lang.Comparable values, using the default comparison- Since:
- 1.4
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExtremumOperator.Extreme
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TaggregateStream(java.util.stream.Stream<T> stream)Calculates the aggregate results from a given stream of values; all values are considered as insertedjava.util.SortedMap<T,java.lang.Integer>clone(java.util.SortedMap<T,java.lang.Integer> original)Clones the given accumulator (with all its internal contents).java.util.SortedMap<T,java.lang.Integer>createNeutral()TgetAggregate(java.util.SortedMap<T,java.lang.Integer> result)static <T extends java.lang.Comparable<T>>
ExtremumOperator<T>getMax()static <T extends java.lang.Comparable<T>>
ExtremumOperator<T>getMin()java.lang.StringgetName()A name or identifier of the operator.java.lang.StringgetShortDescription()A textual description of the operator.booleanisNeutral(java.util.SortedMap<T,java.lang.Integer> result)java.util.SortedMap<T,java.lang.Integer>update(java.util.SortedMap<T,java.lang.Integer> oldResult, T updateValue, boolean isInsertion)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.viatra.query.runtime.matchers.psystem.aggregations.IMultisetAggregationOperator
combine, contains, prettyPrint
-
-
-
-
Method Detail
-
getMin
public static <T extends java.lang.Comparable<T>> ExtremumOperator<T> getMin()
-
getMax
public static <T extends java.lang.Comparable<T>> ExtremumOperator<T> getMax()
-
getShortDescription
public java.lang.String getShortDescription()
Description copied from interface:IMultisetAggregationOperatorA textual description of the operator.- Specified by:
getShortDescriptionin interfaceIMultisetAggregationOperator<T extends java.lang.Comparable<T>,java.util.SortedMap<T extends java.lang.Comparable<T>,java.lang.Integer>,T extends java.lang.Comparable<T>>
-
getName
public java.lang.String getName()
Description copied from interface:IMultisetAggregationOperatorA name or identifier of the operator.
-
createNeutral
public java.util.SortedMap<T,java.lang.Integer> createNeutral()
- Specified by:
createNeutralin interfaceIMultisetAggregationOperator<T extends java.lang.Comparable<T>,java.util.SortedMap<T extends java.lang.Comparable<T>,java.lang.Integer>,T extends java.lang.Comparable<T>>- Returns:
- the neutral element, i.e. the interim result of aggregating an empty multiset.
- Since:
- 2.0
-
isNeutral
public boolean isNeutral(java.util.SortedMap<T,java.lang.Integer> result)
- Specified by:
isNeutralin interfaceIMultisetAggregationOperator<T extends java.lang.Comparable<T>,java.util.SortedMap<T extends java.lang.Comparable<T>,java.lang.Integer>,T extends java.lang.Comparable<T>>- Returns:
- true if the interim result is equivalent to the neutral element, as if there are no values in the multiset. Must return true if the multiset is empty.
- Since:
- 2.0
-
update
public java.util.SortedMap<T,java.lang.Integer> update(java.util.SortedMap<T,java.lang.Integer> oldResult, T updateValue, boolean isInsertion)
- Specified by:
updatein interfaceIMultisetAggregationOperator<T extends java.lang.Comparable<T>,java.util.SortedMap<T extends java.lang.Comparable<T>,java.lang.Integer>,T extends java.lang.Comparable<T>>- Returns:
- an updated intermediate result, changed to reflect that a given object was added to / removed from the multiset (as indicated by the parameter isInsertion)
- Since:
- 2.0
-
getAggregate
public T getAggregate(java.util.SortedMap<T,java.lang.Integer> result)
- Specified by:
getAggregatein interfaceIMultisetAggregationOperator<T extends java.lang.Comparable<T>,java.util.SortedMap<T extends java.lang.Comparable<T>,java.lang.Integer>,T extends java.lang.Comparable<T>>- Returns:
- the aggregate result obtained from the given intermediate result. May be null to indicate that the current multiset cannot be aggregated (e.g. 0 elements have no minimum).
- Since:
- 2.0
-
aggregateStream
public T aggregateStream(java.util.stream.Stream<T> stream)
Description copied from interface:IMultisetAggregationOperatorCalculates the aggregate results from a given stream of values; all values are considered as inserted- Specified by:
aggregateStreamin interfaceIMultisetAggregationOperator<T extends java.lang.Comparable<T>,java.util.SortedMap<T extends java.lang.Comparable<T>,java.lang.Integer>,T extends java.lang.Comparable<T>>- Returns:
- the aggregate result, or null if no result can be calculated (e.g. because of an empty stream)
- Since:
- 2.0
-
clone
public java.util.SortedMap<T,java.lang.Integer> clone(java.util.SortedMap<T,java.lang.Integer> original)
Description copied from interface:IMultisetAggregationOperatorClones the given accumulator (with all its internal contents).
-
-