1- package refined_classes ;
1+ package refined_classes . other ;
22
33import liquidjava .specification .*;
44
1212@ StateSet ({ "empty" , "non-empty" })
1313@ RefinementAlias ("Empty(HashMap h) { size(h) == 0 }" )
1414@ RefinementAlias ("NotEmpty(HashMap h) { size(h) > 0 }" )
15- @ RefinementAlias ("Insert(HashMap h) { size(h) == size(old(h)) + 1 && (size(h) == capacity(h) * loadFactor(h) --> (capacity(h) == capacity(old(h)) * 2)) }" ) // TODO: remove because its aproximatelly double and probably useless
15+ @ RefinementAlias ("Insert(HashMap h) { size(h) == size(old(h)) + 1 }" )
1616@ RefinementAlias ("Remove(HashMap h) { size(h) == size(old(h)) - 1 }" )
17- @ Ghost ("int capacity" )
1817@ Ghost ("int size" )
19- @ Ghost ("float loadFactor" )
2018public abstract class HashMapRefinements <K , V > {
2119
2220 // ======== Constructors ======== //
2321
2422 @ StateRefinement (to = "Empty(this)" )
25- @ StateRefinement (to = "capacity(this) == initialCapacity" )
26- @ StateRefinement (to = "loadFactor(this) == loadFactor" )
2723 public abstract void HashMap (int initialCapacity , float loadFactor );
2824
2925 @ StateRefinement (to = "Empty(this)" )
30- @ StateRefinement (to = "capacity(this) == initialCapacity" )
31- @ StateRefinement (to = "loadFactor(this) == 0.75f" )
3226 public abstract void HashMap (int initialCapacity );
3327
3428 @ StateRefinement (to = "Empty(this)" )
35- @ StateRefinement (to = "capacity(this) == 16" )
36- @ StateRefinement (to = "loadFactor(this) == 0.75f" )
3729 public abstract void HashMap ();
3830
3931 @ StateRefinement (to = "Empty(this) || NotEmpty(this)" )
40- @ StateRefinement (to = "capacity(this) == 0 || capacity(this) > 0" ) // Size of m is inaccessible
41- @ StateRefinement (to = "loadFactor(this) == 0.75f" )
4232 public abstract void HashMap (Map <? extends K , ? extends V > m );
4333
4434 // ======== Observers ========= //
@@ -65,7 +55,6 @@ public abstract class HashMapRefinements<K, V> {
6555 public abstract V put (K key , V value );
6656
6757 @ StateRefinement (to = "size(this) >= size(old(this))" )
68- @ StateRefinement (to = "capacity(this) >= capacity(old(this))" )
6958 public abstract void putAll (@ Refinement ("m != null" ) Map <? extends K , ? extends V > m );
7059
7160 @ StateRefinement (to = "Remove(this)" )
@@ -74,16 +63,16 @@ public abstract class HashMapRefinements<K, V> {
7463 @ StateRefinement (to = "Empty(this)" )
7564 public abstract void clear ();
7665
77- @ StateRefinement (to = "Insert(this) || size(this) = size(old(this))" )
66+ @ StateRefinement (to = "Insert(this) || size(this) == size(old(this))" )
7867 public abstract V computeIfAbsent (K key , @ Refinement ("mappingFunction != null" ) Function <? super K ,? extends V > mappingFunction );
7968
80- @ StateRefinement (to = "Remove(this) || size(this) = size(old(this))" )
69+ @ StateRefinement (to = "Remove(this) || size(this) == size(old(this))" )
8170 public abstract V computeIfPresent (K key , @ Refinement ("remappingFunction != null" ) Function <? super K ,? extends V > remappingFunction );
8271
83- @ StateRefinement (to = "Insert(this) || Remove(this) || size(this) = size(old(this))" )
72+ @ StateRefinement (to = "Insert(this) || Remove(this) || size(this) == size(old(this))" )
8473 public abstract V compute (K key , @ Refinement ("remappingFunction != null" ) BiFunction <? super K ,? super V ,? extends V > remappingFunction );
8574
86- @ StateRefinement (to = "Insert(this) || Remove(this) || size(this) = size(old(this))" )
75+ @ StateRefinement (to = "Insert(this) || Remove(this) || size(this) == size(old(this))" )
8776 public abstract V merge (K key , V value , @ Refinement ("remappingFunction != null" ) BiFunction <? super V ,? super V ,? extends V > remappingFunction );
8877
8978 /* public static newHashMap(int numMappings) Not included because its static */
0 commit comments