Class FreqMap

    • Constructor Detail

      • FreqMap

        public FreqMap​(Map<? extends String,​? extends Long> m)
      • FreqMap

        public FreqMap()
      • FreqMap

        public FreqMap​(int initialCapacity)
      • FreqMap

        public FreqMap​(int initialCapacity,
                       float loadFactor)
      • FreqMap

        public FreqMap​(String initialKey)
    • Method Detail

      • upsert

        public void upsert​(String key,
                           Long value)
        Adds a new key and value to the map if the key is not already there. If the key is already there, the value supplied is added to the existing value for the key and the result is inserted into the map.
        Parameters:
        key - The key in the map to increment or insert.
        value - The value to increment by or initialise to.
      • upsert

        public void upsert​(String key)
        Increments the value of an existing key by 1. If the key doesn't exist, initialises the value to 1.
        Parameters:
        key - The key to increment or insert.
      • getTotal

        public Long getTotal()
        Returns:
        the total frequency.