Package host.anzo.commons.collection
Class MapSplitter<K,V>
java.lang.Object
host.anzo.commons.collection.MapSplitter<K,V>
- Type Parameters:
K- the type of keys maintained by this mapV- the type of mapped values
A utility class that splits a map into smaller chunks.
- Since:
- 6/22/2022
-
Constructor Summary
ConstructorsConstructorDescriptionMapSplitter(Map<K, V> map, int splitCount) Constructs a MapSplitter with the specified map and split count.MapSplitter(Map<K, V> map, Comparator<? super K> comparator, int splitCount) Constructs a MapSplitter with the specified map, comparator, and split count. -
Method Summary
Modifier and TypeMethodDescriptiongetNext()Retrieves the next chunk of the map.getNext(int splitCount) Retrieves the next chunk of the map with the specified split count.booleanhasNext()Checks if there are more chunks available to retrieve.booleanisFirst()Checks if the current chunk is the first chunk.booleanisLast()Checks if the current chunk is the last chunk.intsize()Returns the total number of entries in the map.
-
Constructor Details
-
MapSplitter
Constructs a MapSplitter with the specified map and split count.- Parameters:
map- the map to be splitsplitCount- the number of entries in each chunk
-
MapSplitter
Constructs a MapSplitter with the specified map, comparator, and split count.- Parameters:
map- the map to be splitcomparator- the comparator to order the keyssplitCount- the number of entries in each chunk
-
-
Method Details
-
getNext
Retrieves the next chunk of the map with the specified split count.- Parameters:
splitCount- the number of entries in the next chunk- Returns:
- a map containing the next chunk of entries
-
getNext
Retrieves the next chunk of the map.- Returns:
- a map containing the next chunk of entries
-
size
public int size()Returns the total number of entries in the map.- Returns:
- the size of the map
-
isFirst
public boolean isFirst()Checks if the current chunk is the first chunk.- Returns:
- true if the current chunk is the first chunk, false otherwise
-
isLast
public boolean isLast()Checks if the current chunk is the last chunk.- Returns:
- true if the current chunk is the last chunk, false otherwise
-
hasNext
public boolean hasNext()Checks if there are more chunks available to retrieve.- Returns:
- true if there are more chunks, false otherwise
-