Class UnsettledMap<Delivery>
- Type Parameters:
Delivery- The delivery type being tracker (incoming or outgoing)
- All Implemented Interfaces:
Map<UnsignedInteger,Delivery>
While this class implements the Map interface it does not fully behave
as a standard map as it solves the issue of tracking delivery IDs which always
increase until such time as the unsigned integer value used to represents them
overflows. It is possible (although unlikely) for the same ID to exist for multiple
deliveries if an older delivery exists in the Map and the delivery IDs overflow and
the same value is produced once again.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Set<Map.Entry<UnsignedInteger, Delivery>> protected Set<UnsignedInteger> protected Collection<Delivery> -
Constructor Summary
ConstructorsConstructorDescriptionUnsettledMap(UnsettledMap.UnsettledGetDeliveryId<Delivery> idSupplier) UnsettledMap(UnsettledMap.UnsettledGetDeliveryId<Delivery> idSupplier, int initialBuckets) UnsettledMap(UnsettledMap.UnsettledGetDeliveryId<Delivery> idSupplier, int initialBuckets, int bucketSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(int deliveryId) booleancontainsKey(Object key) booleanbooleancontainsValue(Object value) entrySet()booleanvoidVisits each entry within the given range and invokes the provided action on each delivery in the tracker.voidforEach(BiConsumer<? super UnsignedInteger, ? super Delivery> action) voidVisits each entry within theUnsettledMapand invokes the provided action on each delivery in the tracker.get(int deliveryId) get(UnsignedInteger key) booleanisEmpty()keySet()Adds the given key and value pair in this tracking structure at the end of the current series.put(UnsignedInteger key, Delivery value) voidputAll(Map<? extends UnsignedInteger, ? extends Delivery> source) remove(int deliveryId) remove(UnsignedInteger key) voidremoveEach(int first, int last, Consumer<Delivery> action) Remove each entry within the given range of delivery IDs.intsize()toString()values()Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
keySet
-
values
-
entrySet
-
-
Constructor Details
-
UnsettledMap
-
UnsettledMap
-
UnsettledMap
public UnsettledMap(UnsettledMap.UnsettledGetDeliveryId<Delivery> idSupplier, int initialBuckets, int bucketSize)
-
-
Method Details
-
putAll
- Specified by:
putAllin interfaceMap<UnsignedInteger,Delivery>
-
clear
public void clear()- Specified by:
clearin interfaceMap<UnsignedInteger,Delivery>
-
put
- Specified by:
putin interfaceMap<UnsignedInteger,Delivery>
-
put
Adds the given key and value pair in this tracking structure at the end of the current series.If the map previously contained a mapping for the key, the old value is not replaced by the specified value unlike a traditional map as this structure is tracking the running series of values. This would imply that duplicates can exist in the tracker, however given the likelihood of this occurring in the normal flow of deliveries should be considered extremely low.
- Parameters:
deliveryId- The delivery ID of the delivery being added to this tracker.delivery- The delivery that is being added to the tracker- Returns:
nullin all cases as this Map type does not check for duplicates.
-
size
public int size()- Specified by:
sizein interfaceMap<UnsignedInteger,Delivery>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceMap<UnsignedInteger,Delivery>
-
get
- Specified by:
getin interfaceMap<UnsignedInteger,Delivery>
-
get
-
get
-
remove
- Specified by:
removein interfaceMap<UnsignedInteger,Delivery>
-
remove
-
remove
-
containsKey
- Specified by:
containsKeyin interfaceMap<UnsignedInteger,Delivery>
-
containsKey
-
containsKey
public boolean containsKey(int deliveryId) -
containsValue
- Specified by:
containsValuein interfaceMap<UnsignedInteger,Delivery>
-
forEach
Visits each entry within theUnsettledMapand invokes the provided action on each delivery in the tracker.- Parameters:
action- The action to invoke on each visited entry.
-
forEach
Visits each entry within the given range and invokes the provided action on each delivery in the tracker. The lower and upper bounds are limits which are not exclusive meaning entries within this range are visited regards of there being an exact match on the lower and upper boundaries.- Parameters:
first- The lower bound of the first entry to visit.last- The upper bound of the last entry to visit.action- The action to invoke on each visited entry.
-
removeEach
Remove each entry within the given range of delivery IDs. For each entry removed the provided action is triggered allowing the caller to be notified of each removal.- Parameters:
first- The first entry to removelast- The last entry to removeaction- The action to invoke on each remove.
-
forEach
- Specified by:
forEachin interfaceMap<UnsignedInteger,Delivery>
-
values
- Specified by:
valuesin interfaceMap<UnsignedInteger,Delivery>
-
keySet
- Specified by:
keySetin interfaceMap<UnsignedInteger,Delivery>
-
entrySet
- Specified by:
entrySetin interfaceMap<UnsignedInteger,Delivery>
-
equals
-
toString
-