Class IntersectionSimilarity.TinyBag

  • Enclosing class:
    IntersectionSimilarity<T>

    private class IntersectionSimilarity.TinyBag
    extends java.lang.Object
    A minimal implementation of a Bag that can store elements and a count.

    For the intended purpose the Bag does not have to be a Collection. It does not even have to know its own size.

    • Constructor Summary

      Constructors 
      Constructor Description
      TinyBag​(int initialCapacity)
      Create a new tiny bag.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void add​(T object)
      Adds a new element to the bag, incrementing its count in the underlying map.
      (package private) java.util.Set<java.util.Map.Entry<T,​IntersectionSimilarity.BagCount>> entrySet()
      Returns a Set view of the mappings contained in this bag.
      (package private) int getCount​(java.lang.Object object)
      Returns the number of occurrence of the given element in this bag by looking up its count in the underlying map.
      (package private) int uniqueElementSize()
      Get the number of unique elements in the bag.
      • Methods inherited from class java.lang.Object

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

      • TinyBag

        TinyBag​(int initialCapacity)
        Create a new tiny bag.
        Parameters:
        initialCapacity - the initial capacity
    • Method Detail

      • add

        void add​(T object)
        Adds a new element to the bag, incrementing its count in the underlying map.
        Parameters:
        object - the object to add
      • entrySet

        java.util.Set<java.util.Map.Entry<T,​IntersectionSimilarity.BagCount>> entrySet()
        Returns a Set view of the mappings contained in this bag.
        Returns:
        The Set view
      • getCount

        int getCount​(java.lang.Object object)
        Returns the number of occurrence of the given element in this bag by looking up its count in the underlying map.
        Parameters:
        object - the object to search for
        Returns:
        The number of occurrences of the object, zero if not found
      • uniqueElementSize

        int uniqueElementSize()
        Get the number of unique elements in the bag.
        Returns:
        The unique element size