Class TwoColumnRangeStructure<K extends Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>,R>
- All Implemented Interfaces:
MergeAndCopyStructure<TwoColumnRangeStructure<K,V, R>>
SearchStructure that maps ranges (keys) to nested SearchStructures i.e. sets of values. Each range in a
TwoColumnRangeStructure is defined by lower and upper bound. Thus there might be "gaps"
in between ranges, in contrast to RangeStructures. The
TwoColumnRangeStructure also supports overlapping ranges, as well as "infinite" ranges.
Ranges are set up by putting one or more key-key-value tuples into this structure. The keys are
of a comparable data type (of course, as they define a range). The value is a nested
SearchStructure. The first key defines the lower bound, the second the upper bound of the
range. The value can be retrieved by calling get(Object) with a key inside the defined
range.
Example: In a TwoColumnRangeStructure by calling put(10, 24, "AAA") and
put(25, 50, "BBB"), two ranges are defined. Calls to get(Object) with the:
- keys 10, 24 and all in between will yield {"AAA"} as a result
- keys 25, 50 and all in between will yield {"BBB"} respectively
- keys outside these ranges, e.g. 0 or 100 will return an
EmptySearchStructure.
Overlapping ranges: In a TwoColumnRangeStructure by calling
put(0, 100, "AAA") and put(50, 200, "BBB"), two ranges are defined.
Calls to get(Object) with keys:
- keys 0, 49 and all in between will yield {"AAA"} as a result
- keys 101, 200 and all in between will yield {"BBB"} respectively
- keys in the overlapping, 50, 100 and all in between, will yield the set union {"AAA", "BBB"} as a result
- keys outside these ranges, e.g. -100 or 500 will return an
EmptySearchStructure.
Calling put(null, 100, "AAA") defines a range from negative infinity to 100, that
maps to {"AAA"}. This range includes all values less than and equal to 100. Calling
put(0, null, "BBB") in turn defines a range from 0 to positive infinity. This range
includes all values greater than and equal to 0.
-
Method Summary
Modifier and TypeMethodDescriptioncopy()This method copies the object which calls it.static <K extends Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>, R>
TwoColumnRangeStructure<K,V, R> create()Creates an emptyTwoColumnRangeStructure.static <K extends Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>, R>
TwoColumnRangeStructure<K,V, R> createWith(K lowerBound, K upperBound, V value) Creates a newTwoColumnRangeStructureand adds the given range-value pair.Returns the nestedSearchStructurefor the given key.getMap()voidmerge(TwoColumnRangeStructure<K, V, R> map) Merging adds the contents of the otherMergable to this object.voidDefines a range that maps to the given value.voidDefines a range that maps to the given value.voidPuts a new element in the map.Methods inherited from class org.faktorips.runtime.internal.tableindex.AbstractMapStructure
emptyResult, fillCopy, get, getValidResult, mergeMethods inherited from class org.faktorips.runtime.internal.tableindex.SearchStructure
getUnique, getUnique
-
Method Details
-
create
public static <K extends Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>, TwoColumnRangeStructure<K,R> V, create()R> Creates an emptyTwoColumnRangeStructure. -
createWith
public static <K extends Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>, TwoColumnRangeStructure<K,R> V, createWithR> (K lowerBound, K upperBound, V value) Creates a newTwoColumnRangeStructureand adds the given range-value pair. -
put
Defines a range that maps to the given value. The keys define the upper and lower bound of the range. The lower and upper bounds are inclusive.- Parameters:
lower- the lower bound of the range (included)upper- the upper bound of the range (included)value- the nestedSearchStructureto be added
-
put
Defines a range that maps to the given value. The keys define the upper and lower bound of the range.If the lower bound is greater than upper bound, the lower and upper bound are automatically switched (including lower- and upper-inclusive parameter).
- Parameters:
lower- the lower bound of the range (included)upper- the upper bound of the range (included)lowerInclusive-trueif the lower bound should be inclusive,falseif it should be exclusiveupperInclusive-trueif the upper bound should be inclusive,falseif it should be exclusivevalue- the nestedSearchStructureto be added
-
put
Description copied from class:AbstractMapStructurePuts a new element in the map. If there is already a value for the given key, the two values will be merged together. Thus existing values will never be overwritten.- Overrides:
putin classAbstractMapStructure<org.faktorips.runtime.internal.tableindex.TwoColumnRange<K extends Comparable<? super K>>,V extends SearchStructure<R> & MergeAndCopyStructure<V>, R> - Parameters:
key- key that maps to the specified valuevalue- value to be associated with the specified key.- See Also:
-
getMap
- Overrides:
getMapin classAbstractMapStructure<org.faktorips.runtime.internal.tableindex.TwoColumnRange<K extends Comparable<? super K>>,V extends SearchStructure<R> & MergeAndCopyStructure<V>, R>
-
get
Description copied from class:SearchStructureReturns the nestedSearchStructurefor the given key. This method never returnsnull. If no value exists for a given key anEmptySearchStructureis returned as a fall-back.- Specified by:
getin classSearchStructure<R>- Parameters:
key- The key for the requested nestedSearchStructure- Returns:
- The nested
SearchStructureor anEmptySearchStructureif the key does not exist.
-
merge
Description copied from interface:MergeAndCopyStructureMerging adds the contents of the otherMergable to this object. This object then contains the combined content. The other object remains unchanged.Merging aSearchStructuredeletes no content, instead equal values are being merged recursively.- Specified by:
mergein interfaceMergeAndCopyStructure<K extends Comparable<? super K>>- Parameters:
map- The object that should be merged into this object
-
copy
Description copied from interface:MergeAndCopyStructureThis method copies the object which calls it. The newly created object has the same properties like the object callingMergeAndCopyStructure.copy().- Specified by:
copyin interfaceMergeAndCopyStructure<K extends Comparable<? super K>>- Returns:
- T that is a copy of the calling object
-