Class MultiSet<T>
java.lang.Object
adaa.analytics.rules.logic.representation.MultiSet<T>
- Type Parameters:
T
- Type of elements stored in a set.
- All Implemented Interfaces:
Serializable
,Iterable<T>
Generic class representing a multiset.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionCollection storing elements with their multiplicityprotected int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds an element to the multiset (increments multiplicity by 1).boolean
Adds an element to the multiset given number of times (increments multiplicity by this number).void
clear()
boolean
Verifies the multiset contains a given element.int
Gets multiplicity of a specified element.iterator()
Multiset iterator.int
Gets multisize of the multiset.void
Removes element from the multiset.int
size()
Gets size of the multiset.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
map
Collection storing elements with their multiplicity -
totalCount
protected int totalCount
-
-
Constructor Details
-
MultiSet
public MultiSet()
-
-
Method Details
-
contains
Verifies the multiset contains a given element.- Parameters:
v
- Elements to be verified.- Returns:
- Verification result.
-
add
Adds an element to the multiset (increments multiplicity by 1).- Parameters:
v
- Element to be added.- Returns:
- Should be ignored - always true.
-
add
Adds an element to the multiset given number of times (increments multiplicity by this number).- Parameters:
v
- Element to be added.count
- Multiplicity of the element being added.- Returns:
- Should be ignored - always true.
-
getCount
Gets multiplicity of a specified element.- Parameters:
v
- Element to be found in the set.- Returns:
- Multiplicity of the element (0 if it doesn't exist).
-
remove
Removes element from the multiset.- Parameters:
v
- Elements to be removed.
-
clear
public void clear() -
size
public int size()Gets size of the multiset.- Returns:
- Number of unique elements in the multiset.
-
multisize
public int multisize()Gets multisize of the multiset.- Returns:
- Number of all elements in the multiset.
-
iterator
Multiset iterator.
-