Class LimitedInMemorySortedIterable<E>
- java.lang.Object
-
- uk.gov.gchq.gaffer.commonutil.iterable.LimitedInMemorySortedIterable<E>
-
- Type Parameters:
E
- the type of object to store in theLimitedInMemorySortedIterable
.
- All Implemented Interfaces:
Iterable<E>
public class LimitedInMemorySortedIterable<E> extends Object implements Iterable<E>
An
Iterable
which can sort, limit and deduplicate its elements. Sorting is achieved with a providedComparator
.This iterable is backed by a
TreeMap
, with items being dropped from the end of the backing TreeMap. To allow duplicates and to be stored the TreeMap is a map of item to collection of items. The tree map uses the comparator for equality checking, so the collection of items will contain items with a comparator score of 0, but potentially not equal using the equals method.
-
-
Constructor Summary
Constructors Constructor Description LimitedInMemorySortedIterable(Comparator<E> comparator)
LimitedInMemorySortedIterable(Comparator<E> comparator, Integer limit)
LimitedInMemorySortedIterable(Comparator<E> comparator, Integer limit, boolean deduplicate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E e)
boolean
addAll(Iterable<E> items)
boolean
equals(Object obj)
int
hashCode()
Iterator<E>
iterator()
int
size()
String
toString()
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
LimitedInMemorySortedIterable
public LimitedInMemorySortedIterable(Comparator<E> comparator)
-
LimitedInMemorySortedIterable
public LimitedInMemorySortedIterable(Comparator<E> comparator, Integer limit)
-
LimitedInMemorySortedIterable
public LimitedInMemorySortedIterable(Comparator<E> comparator, Integer limit, boolean deduplicate)
-
-
Method Detail
-
add
public boolean add(E e)
-
size
public int size()
-
-