mirror of
https://github.com/corda/corda.git
synced 2025-04-26 13:59:56 +00:00
implement first() and last() in TreeSet
This commit is contained in:
parent
84bcbbcaa3
commit
a8bb0d074b
@ -41,6 +41,18 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
|
|||||||
add(item);
|
add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T first() {
|
||||||
|
if (isEmpty()) throw new NoSuchElementException();
|
||||||
|
|
||||||
|
return set.first().value().value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T last() {
|
||||||
|
if (isEmpty()) throw new NoSuchElementException();
|
||||||
|
|
||||||
|
return set.last().value().value;
|
||||||
|
}
|
||||||
|
|
||||||
public Iterator<T> iterator() {
|
public Iterator<T> iterator() {
|
||||||
return new MyIterator<T>(set.first());
|
return new MyIterator<T>(set.first());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user