Skip to content

Instantly share code, notes, and snippets.

@yurii-litvinov
Created October 5, 2016 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurii-litvinov/ce846717a7d86153fd639fb0ae060b78 to your computer and use it in GitHub Desktop.
Save yurii-litvinov/ce846717a7d86153fd639fb0ae060b78 to your computer and use it in GitHub Desktop.
Interface of Multiset
package task;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
public interface Multiset<E> extends Collection<E> {
/**
* Returns the number of occurrences of an element in this multiset.
* <p>
* Expected complexity: Same as `contains`
*/
int count(Object element);
/**
* Returns the set of distinct elements contained in this multiset.
* <p>
* Expected complexity: O(1)
*/
Set<E> elementSet();
/**
* Returns the set of entries representing the data of this multiset.
* <p>
* Expected complexity: O(1)
*/
Set<Entry<E>> entrySet();
/**
* Elements that occur multiple times in the multiset will appear multiple times in this iterator.
* <p>
* Expected complexity: O(1)
*/
@Override
Iterator<E> iterator();
interface Entry<E> {
E getElement();
int getCount();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment