Multiset (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.search, class: Multiset

Package org.apache.lucene.search

# Class Multiset<T>

java.lang.Object
java.util.AbstractCollection<T>
org.apache.lucene.search.Multiset<T>

All Implemented Interfaces:
  `Iterable<T>`, `Collection<T>`

public final class Multiset<T> extends AbstractCollection<T>
A `Multiset` is a set that allows for duplicate elements. Two `Multiset`s are equal if they contain the same unique elements and if each unique element has as many occurrences in both multisets. Iteration order is not specified.

NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Multiset()`
  Create an empty `Multiset`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `add(T e)`
  `void`
  `clear()`
  `boolean`
  `contains(Object o)`
  `boolean`
  `equals(Object obj)`
  `int`
  `hashCode()`
  `Iterator<T>`
  `iterator()`
  `boolean`
  `remove(Object o)`
  `int`
  `size()`

  ### Methods inherited from class java.util.AbstractCollection

  `addAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.util.Collection

  `parallelStream, removeIf, spliterator, stream, toArray`

  ### Methods inherited from interface java.lang.Iterable

  `forEach`

- ## Constructor Details

  - ### Multiset

    public Multiset()
    Create an empty `Multiset`.

- ## Method Details

  - ### iterator

    public Iterator<T> iterator()
    Specified by:
      `iterator` in interface `Collection<T>`
    Specified by:
      `iterator` in interface `Iterable<T>`
    Specified by:
      `iterator` in class `AbstractCollection<T>`

  - ### size

    public int size()
    Specified by:
      `size` in interface `Collection<T>`
    Specified by:
      `size` in class `AbstractCollection<T>`

  - ### clear

    public void clear()
    Specified by:
      `clear` in interface `Collection<T>`
    Overrides:
      `clear` in class `AbstractCollection<T>`

  - ### add

    public boolean add(T e)
    Specified by:
      `add` in interface `Collection<T>`
    Overrides:
      `add` in class `AbstractCollection<T>`

  - ### remove

    public boolean remove(Object o)
    Specified by:
      `remove` in interface `Collection<T>`
    Overrides:
      `remove` in class `AbstractCollection<T>`

  - ### contains

    public boolean contains(Object o)
    Specified by:
      `contains` in interface `Collection<T>`
    Overrides:
      `contains` in class `AbstractCollection<T>`

  - ### equals

    public boolean equals(Object obj)
    Specified by:
      `equals` in interface `Collection<T>`
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Specified by:
      `hashCode` in interface `Collection<T>`
    Overrides:
      `hashCode` in class `Object`