Class MapSplitter<K,V>

java.lang.Object
host.anzo.commons.collection.MapSplitter<K,V>
Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values

public class MapSplitter<K,V> extends Object
A utility class that splits a map into smaller chunks.
Since:
6/22/2022
  • Constructor Summary

    Constructors
    Constructor
    Description
    MapSplitter(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 Type
    Method
    Description
    Retrieves the next chunk of the map.
    getNext(int splitCount)
    Retrieves the next chunk of the map with the specified split count.
    boolean
    Checks if there are more chunks available to retrieve.
    boolean
    Checks if the current chunk is the first chunk.
    boolean
    Checks if the current chunk is the last chunk.
    int
    Returns the total number of entries in the map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MapSplitter

      public MapSplitter(Map<K,V> map, int splitCount)
      Constructs a MapSplitter with the specified map and split count.
      Parameters:
      map - the map to be split
      splitCount - the number of entries in each chunk
    • MapSplitter

      public MapSplitter(Map<K,V> map, Comparator<? super K> comparator, int splitCount)
      Constructs a MapSplitter with the specified map, comparator, and split count.
      Parameters:
      map - the map to be split
      comparator - the comparator to order the keys
      splitCount - the number of entries in each chunk
  • Method Details

    • getNext

      public Map<K,V> getNext(int splitCount)
      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

      public Map<K,V> 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