T
- the type of elements to store into the multisetpublic class MultiSet<T extends java.io.Serializable>
extends java.util.HashMap<T,java.lang.Integer>
Constructor and Description |
---|
MultiSet() |
Modifier and Type | Method and Description |
---|---|
java.lang.Integer |
add(T element,
java.lang.Integer incrementFactor)
This method adds and, in case, increments the frequency of an element
into the current multiset by the provided increment factor
|
boolean |
equals(java.lang.Object other) |
java.util.HashSet<T> |
getSimpleSet()
This method returns the set of elements without multiplicity
|
static <T extends java.io.Serializable> |
intersection(MultiSet<T> set1,
MultiSet<T> set2)
This static method intersects two multisets
|
void |
put(T element)
This method adds and, in case, increments the frequency of an element
into the current multiset
|
void |
remove(T key,
int freq)
This method removes the given element the number of times provided
|
int |
size() |
java.lang.String |
toString() |
static <T extends java.io.Serializable> |
union(MultiSet<T> set1,
MultiSet<T> set2)
This static method merges the two given multisets.
|
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, values
public void put(T element)
element
- the element to addpublic java.lang.Integer add(T element, java.lang.Integer incrementFactor)
element
- the element to addincrementFactor
- the factor to sumpublic static <T extends java.io.Serializable> MultiSet<T> union(MultiSet<T> set1, MultiSet<T> set2)
set1
- the first setset2
- the second setpublic static <T extends java.io.Serializable> MultiSet<T> intersection(MultiSet<T> set1, MultiSet<T> set2)
set1
- the first setset2
- the second setpublic void remove(T key, int freq)
key
- the element to removefreq
- the number of occurrences to removepublic java.util.HashSet<T> getSimpleSet()
public int size()
public boolean equals(java.lang.Object other)
public java.lang.String toString()
toString
in class java.util.AbstractMap<T extends java.io.Serializable,java.lang.Integer>