Class PacketTypeMultiMap<T>
java.lang.Object
com.comphenix.protocol.concurrent.PacketTypeMultiMap<T>
- Type Parameters:
T- the type of elements maintained by this map
A map-like data structure that associates
PacketTypes with sets of
values. The values are stored in a SortedCopyOnWriteSet, which
ensures that the elements are kept in a sorted order based on the
ListenerPriority of the ListeningWhitelist, while maintaining
their insertion order for elements with equal priorities.
This class is thread-safe for modifications and guarantees a modification-free iteration of associated values per packet type. All read methods work on a lock-free, best-effort principle, ensuring fast access.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all entries from the map.booleancontains(PacketType packetType) Checks if a specifiedPacketTypeis contained in the map.get(PacketType packetType) Returns an iterable of values associated with a specifiedPacketType.com.google.common.collect.ImmutableSet<PacketType> Returns an immutable set of allPacketTypes currently in the map.voidput(ListeningWhitelist key, T value) Adds a value to the map, associating it with thePacketTypes contained in the specifiedListeningWhitelist.remove(ListeningWhitelist key, T value) Removes a value from the map, disassociating it from thePacketTypes contained in the specifiedListeningWhitelist.values()
-
Constructor Details
-
PacketTypeMultiMap
public PacketTypeMultiMap()
-
-
Method Details
-
put
Adds a value to the map, associating it with thePacketTypes contained in the specifiedListeningWhitelist. If the value is already present in the set (as determined byequals), it will not be added again.- Parameters:
key- the whitelist containing the packet types to associate the value withvalue- the value to be added- Throws:
NullPointerException- if the key or value is null
-
remove
Removes a value from the map, disassociating it from thePacketTypes contained in the specifiedListeningWhitelist. If the value is not present, the map remains unchanged.- Parameters:
key- the whitelist containing the packet types to disassociate the value fromvalue- the value to be removed- Returns:
- a list of packet types that got removed because they don't have any associated values anymore
- Throws:
NullPointerException- if the key or value is null
-
getPacketTypes
Returns an immutable set of allPacketTypes currently in the map.- Returns:
- an immutable set of packet types
-
contains
Checks if a specifiedPacketTypeis contained in the map.- Parameters:
packetType- the packet type to check for- Returns:
trueif the packet type is contained in the map,falseotherwise
-
get
Returns an iterable of values associated with a specifiedPacketType. If no values are associated with the packet type, an empty iterator is returned.- Parameters:
packetType- the packet type to retrieve values for- Returns:
- an iterable of values associated with the packet type
-
values
-
clear
public void clear()Clears all entries from the map.
-