mirror of
https://github.com/corda/corda.git
synced 2025-06-13 20:58:19 +00:00
implement first() and last() in TreeSet
This commit is contained in:
@ -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());
|
||||||
|
Reference in New Issue
Block a user