Class IntersectionSimilarity.TinyBag
java.lang.Object
org.apache.commons.text.similarity.IntersectionSimilarity.TinyBag
- Enclosing class:
- IntersectionSimilarity<T>
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<T,
IntersectionSimilarity.BagCount> The backing map. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
Adds a new element to the bag, incrementing its count in the underlying map.(package private) Set<Map.Entry<T,
IntersectionSimilarity.BagCount>> entrySet()
Returns a Set view of the mappings contained in this bag.(package private) int
Returns the number of occurrence of the given element in this bag by looking up its count in the underlying map.(package private) int
Get the number of unique elements in the bag.
-
Field Details
-
map
The backing map.
-
-
Constructor Details
-
TinyBag
TinyBag(int initialCapacity) Create a new tiny bag.- Parameters:
initialCapacity
- the initial capacity
-
-
Method Details
-
add
Adds a new element to the bag, incrementing its count in the underlying map.- Parameters:
object
- the object to add
-
getCount
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
-
entrySet
Set<Map.Entry<T,IntersectionSimilarity.BagCount>> entrySet()Returns a Set view of the mappings contained in this bag.- Returns:
- The Set view
-
uniqueElementSize
int uniqueElementSize()Get the number of unique elements in the bag.- Returns:
- The unique element size
-