It is assumed that the type T correctly conforms to the requirements for storage
within a Set or HashMap. Ideally the type is immutable and implements
Object#equals(Object) and Object#hashCode().
Set, HashMap
| Modifier and Type | Class and Description |
|---|---|
| private static class | IntersectionSimilarity.
Mutable counter class for storing the count of elements. |
| private class | IntersectionSimilarity.
A minimal implementation of a Bag that can store elements and a count. |
| Modifier and Type | Field and Description |
|---|---|
| private final Function | converter
The converter used to create the elements from the characters. |
| Access | Constructor and Description |
|---|---|
| public | IntersectionSimilarity(final Function<CharSequence, Collection<T>>
the converter used to create the elements from the characters. converter)Create a new intersection similarity using the provided converter. |
| Modifier and Type | Method and Description |
|---|---|
| public IntersectionResult | Returns: The intersection result.first character sequence. left, final CharSequence second character sequence. right)Implements org. Calculates the intersection of two character sequences passed as input. |
| private static < the type of the elements in the set. T> int | Returns: The intersection of A and B.the set A. setA, final Set<T> the set B. setB)Computes the intersection between two sets. |
| private int | Returns: The intersection of A and B.the bag A. bagA,the bag B. bagBComputes the intersection between two bags. |
| private IntersectionSimilarity |
| converter | back to summary |
|---|---|
| private final Function<CharSequence, Collection<T>> converter The converter used to create the elements from the characters. | |
| IntersectionSimilarity | back to summary |
|---|---|
| public IntersectionSimilarity(final Function<CharSequence, Collection<T>> converter) Create a new intersection similarity using the provided converter.
If the converter returns a
| |
| apply | back to summary |
|---|---|
| public IntersectionResult apply(final CharSequence left, final CharSequence right) Implements org. Calculates the intersection of two character sequences passed as input.
| |
| getIntersection | back to summary |
|---|---|
| private static <T> int getIntersection(final Set<T> setA, final Set<T> setB) Computes the intersection between two sets. This is the count of all the elements that are within both sets. | |
| getIntersection | back to summary |
|---|---|
| private int getIntersection(final IntersectionSimilarity<T>. Computes the intersection between two bags. This is the sum of the minimum count of each element that is within both sets.
| |
| toBag | back to summary |
|---|---|
| private IntersectionSimilarity Converts the collection to a bag. The bag will contain the count of each element in the collection.
| |
| Modifier and Type | Field and Description |
|---|---|
| private int | count
The count. |
| private static final IntersectionSimilarity. | ZERO
Private, mutable but must be used as immutable. |
| Access | Constructor and Description |
|---|---|
| private |
| count | back to summary |
|---|---|
| private int count The count. | |
| ZERO | back to summary |
|---|---|
| private static final IntersectionSimilarity. Private, mutable but must be used as immutable. | |
| BagCount | back to summary |
|---|---|
| private BagCount() | |
For the intended purpose the Bag does not have to be a Collection. It does not
even have to know its own size.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | map
The backing map. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private void | add(final T
the object to add. object)Adds a new element to the bag, incrementing its count in the underlying map. |
| private Set | |
| private int | |
| private int |
| map | back to summary |
|---|---|
| private final Map<T, IntersectionSimilarity. The backing map. | |
| TinyBag | back to summary |
|---|---|
| private TinyBag(final int initialCapacity) Create a new tiny bag.
| |
| add | back to summary |
|---|---|
| private void add(final T object) Adds a new element to the bag, incrementing its count in the underlying map.
| |
| entrySet | back to summary |
|---|---|
| private Set Returns a Set view of the mappings contained in this bag.
| |
| getCount | back to summary |
|---|---|
| private int getCount(final Object object) Returns the number of occurrence of the given element in this bag by looking up its count in the underlying map.
| |
| uniqueElementSize | back to summary |
|---|---|
| private int uniqueElementSize() Gets the number of unique elements in the bag.
| |