-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathTopK.java
More file actions
35 lines (26 loc) · 845 Bytes
/
TopK.java
File metadata and controls
35 lines (26 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
Interface that defines the public API of the "TopK" data
structure that keeps only the "best" values added according to a
given Comparator.
Based on Bailey's Java Structures Chapter 11 Lab.
@author Jim Teresco
@version Spring 2021
*/
public interface TopK<E> extends Iterable<E> {
/**
Add a new element to the TopK.
@param item the element to add
*/
public void add(E item);
/**
Return the number of elements currently stored in the structure.
Note that this would never be larger than the "K" value that
will be specified to the constructor of an implementing class.
@return the number of elements currently stored in the structure
*/
public int size();
/**
Clear the contents of the structure.
*/
public void clear();
}