Skip to content

Commit

Permalink
Added back the two assert statements, test should fail before pushing…
Browse files Browse the repository at this point in the history
… updated first(), last(), and isEmpty() (#1996)

Added back changed that got lost in rebase

Remove/detect star imports in repo (#1977)

* Beginning to weed out star imports

* More removal of star imports

* Adding junit4 patterns to restricted list

* Updating deprecated imports

* Cleaning up the restrict blocks a bit, fixing regex for stars

* Trimming down excess restrictions

* Ensuring no junit3s come back in

---------

Co-authored-by: pcagbu <[email protected]>

Fixed incorrect argument to planQuery (#2015)

Co-authored-by: Jeffrey Schmidt jjschm4 <[email protected]>

remove autoupdate workflow (#2017)

reorganize imports with -Pexamples

Updates per peer review

Feature/2.1.1 (#2037)

* move from accumulo 2.1.0 to accumulo2.1.1

Feature/2.1.1 (#2037)

* move from accumulo 2.1.0 to accumulo2.1.1
  • Loading branch information
MiguelRicardos authored Aug 21, 2023
1 parent 736bca2 commit fe2e12b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.SortedSet;
import java.util.TreeSet;

Expand Down Expand Up @@ -52,8 +53,11 @@ public int size() {

@Override
public boolean isEmpty() {
if (sets == null) {
return true;
}
for (SortedSet<E> set : sets) {
if (!set.isEmpty()) {
if (set != null && !set.isEmpty()) {
return false;
}
}
Expand Down Expand Up @@ -141,26 +145,38 @@ public SortedSet<E> tailSet(E fromElement) {
}

@Override
public E first() {
public E first() throws NoSuchElementException {
if (sets == null || sets.isEmpty()) {
throw new NoSuchElementException("No elements in input sets");
}
SortedSet<E> firstSet = new TreeSet<>(comparator());
for (SortedSet<E> set : sets) {
E s = set.first();
if (s != null) {
if (set != null && !set.isEmpty()) {
E s = set.first();
firstSet.add(s);
}
}
if (firstSet.isEmpty()) {
throw new NoSuchElementException("No elements in input sets");
}
return firstSet.first();
}

@Override
public E last() {
public E last() throws NoSuchElementException {
if (sets == null || sets.isEmpty()) {
throw new NoSuchElementException("No elements in input sets");
}
SortedSet<E> lastSet = new TreeSet<>(comparator());
for (SortedSet<E> set : sets) {
E s = set.last();
if (s != null) {
if (set != null && !set.isEmpty()) {
E s = set.last();
lastSet.add(s);
}
}
if (lastSet.isEmpty()) {
throw new NoSuchElementException("No elements in input sets");
}
return lastSet.last();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,14 @@ public void testHeadSet() {
// verify order
assertFalse(subSet.isEmpty());
assertArrayEquals(data[sortedOrder[start]], subSet.iterator().next());
assertArrayEquals(data[sortedOrder[start]], subSet.first());
int index = start;
for (byte[] value : subSet) {
assertArrayEquals(data[sortedOrder[index++]], value);
}
ArrayList<byte[]> list = new ArrayList<>(subSet);
assertArrayEquals(data[sortedOrder[end - 1]], list.get(list.size() - 1));
assertArrayEquals(data[sortedOrder[end - 1]], subSet.last());

subSet = set.headSet(data[sortedOrder[end]]);

Expand Down

0 comments on commit fe2e12b

Please sign in to comment.