Package components.map
Class Map2<K,V>
java.lang.Object
components.map.MapSecondary<K,V>
components.map.Map2<K,V>
- Type Parameters:
K
- type ofMap
domain (key) entriesV
- type ofMap
range (associated value) entries
Map
represented as a Queue
of pairs with implementations of
primary methods.- Representation Invariant (concrete invariant of $this):
for all key1, key2: K, value1, value2: V, str1, str2: string of (key, value) where (str1 * <(key1, value1)> is prefix of $this.pairsQueue and str2 * <(key2, value2)> is prefix of $this.pairsQueue and str1 /= str2) (key1 /= key2)
- Abstraction Relation (interpretation mapping between $this and this):
this = entries($this.pairsQueue)
-
Nested Class Summary
Nested classes/interfaces inherited from class components.map.MapSecondary
MapSecondary.SimplePair<K,
V> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
Adds the pair (key
,value
) to this.final void
clear()
Resetsthis
to an initial value.final boolean
Reports whether there is a pair inthis
whose first component iskey
.iterator()
Returns a new object with the same dynamic type asthis
, having an initial value.Removes the pair whose first component iskey
and returns it.Removes and returns an arbitrary pair fromthis
.final int
size()
Reports size ofthis
.final void
transferFrom
(Map<K, V> source) Setsthis
to the incoming value ofsource
, and resetssource
to an initial value; the declaration notwithstanding, the dynamic type ofsource
must be the same as the dynamic type ofthis
.final V
Reports the value associated withkey
inthis
.Methods inherited from class components.map.MapSecondary
combineWith, equals, hashCode, hasValue, key, replaceValue, sharesKeyWith, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Map2
public Map2()No-argument constructor.
-
-
Method Details
-
newInstance
Description copied from interface:Standard
Returns a new object with the same dynamic type asthis
, having an initial value. If the typeT
has a no-argument constructor, then the value of the new returned object satisfies the contract of the no-argument constructor forT
. IfT
does 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"
this
with an initial value
-
clear
Description copied from interface:Standard
Resetsthis
to an initial value. If the typeT
has a no-argument constructor, thenthis
satisfies the contract of the no-argument constructor forT
. IfT
does not have a no-argument constructor, thenthis
satisfies the contract of the constructor call that was used to initialize#this
. -
transferFrom
Description copied from interface:Standard
Setsthis
to the incoming value ofsource
, and resetssource
to an initial value; the declaration notwithstanding, the dynamic type ofsource
must be the same as the dynamic type ofthis
. If the typeT
has a no-argument constructor, thensource
satisfies the contract of the no-argument constructor forT
. IfT
does not have a no-argument constructor, thensource
satisfies the contract of the constructor call that was used to initialize#source
.- Parameters:
source
- object whose value is to be transferred
-
add
Description copied from interface:MapKernel
Adds the pair (key
,value
) to this.- Parameters:
key
- the key to be addedvalue
- the associated value to be added
-
remove
Description copied from interface:MapKernel
Removes the pair whose first component iskey
and returns it.- Parameters:
key
- the key to be removed- Returns:
- the pair removed
-
removeAny
Description copied from interface:MapKernel
Removes and returns an arbitrary pair fromthis
.- Returns:
- the pair removed from
this
-
value
Description copied from interface:MapKernel
Reports the value associated withkey
inthis
.- Parameters:
key
- the key whose associated value is to be reported- Returns:
- the value associated with key
-
hasKey
Description copied from interface:MapKernel
Reports whether there is a pair inthis
whose first component iskey
.- Parameters:
key
- the key to be checked- Returns:
- true iff there is a pair in this whose first component is
key
-
size
Description copied from interface:MapKernel
Reports size ofthis
.- Returns:
- the number of pairs in
this
-
iterator
-