Class Map3<K,V>
java.lang.Object
components.map.MapSecondary<K,V>
components.map.Map3<K,V>
- Type Parameters:
K- type ofMapdomain (key) entriesV- type ofMaprange (associated value) entries
Map represented as a BinaryTree (maintained as a binary
search tree) of pairs with implementations of primary methods.- Mathematical Definitions:
IS_TOTAL_PREORDER ( r: binary relation on K ) : boolean is for all x, y, z: K ((r(x, y) or r(y, x)) and (if (r(x, y) and r(y, z)) then r(x, z))) IS_BST( tree: binary tree of (K, V), r: binary relation on K ): boolean satisfies [tree satisfies the binary search tree ordering property according to the relation r on the keys of its (K, V) labels and has no duplicate key values among its (K, V) labels]- Representation Invariant (concrete invariant of $this):
IS_TOTAL_PREORDER([relation computed by $this.order.compare method] and IS_BST($this.pairsTree, $this.order)- Abstraction Relation (interpretation mapping between $this and this):
this = labels($this.pairsTree)
-
Nested Class Summary
Nested classes/interfaces inherited from class MapSecondary
MapSecondary.SimplePair<K,V> -
Constructor Summary
ConstructorsConstructorDescriptionMap3()No-argument constructor: usesComparable'scompareToorder if available; otherwise, compareshashCodes.Map3(Comparator<K> order) Constructor using givenComparator'scompareorder. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidAdds the pair (key,value) to this.final voidclear()Resetsthisto an initial value.final booleanReports whether there is a pair inthiswhose first component iskey.iterator()Returns a new object with the same dynamic type asthis, having an initial value.Removes the pair whose first component iskeyand returns it.Removes and returns an arbitrary pair fromthis.final intsize()Reports size ofthis.final voidtransferFrom(Map<K, V> source) Setsthisto the incoming value ofsource, and resetssourceto an initial value; the declaration notwithstanding, the dynamic type ofsourcemust be the same as the dynamic type ofthis.final VReports the value associated withkeyinthis.Methods inherited from class MapSecondary
combineWith, equals, hashCode, hasValue, key, replaceValue, sharesKeyWith, toStringMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
Map3
public Map3()No-argument constructor: usesComparable'scompareToorder if available; otherwise, compareshashCodes. -
Map3
Constructor using givenComparator'scompareorder.- Parameters:
order- the order for the BST
-
-
Method Details
-
newInstance
Description copied from interface:StandardReturns a new object with the same dynamic type asthis, having an initial value. If the typeThas a no-argument constructor, then the value of the new returned object satisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, then the value of the new returned object satisfies the contract of the constructor call that was used to initializethis.- Returns:
- new object "like"
thiswith an initial value
-
clear
Description copied from interface:StandardResetsthisto an initial value. If the typeThas a no-argument constructor, thenthissatisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, thenthissatisfies the contract of the constructor call that was used to initialize#this. -
transferFrom
Description copied from interface:StandardSetsthisto the incoming value ofsource, and resetssourceto an initial value; the declaration notwithstanding, the dynamic type ofsourcemust be the same as the dynamic type ofthis. If the typeThas a no-argument constructor, thensourcesatisfies the contract of the no-argument constructor forT. IfTdoes not have a no-argument constructor, thensourcesatisfies the contract of the constructor call that was used to initialize#source.- Parameters:
source- object whose value is to be transferred
-
add
-
remove
-
removeAny
-
value
-
hasKey
-
size
-
iterator
-