use of java.util.NavigableSet in project jdk8u_jdk by JetBrains.
the class EmptyNavigableSet method testHeadSet.
/**
* Tests the headSet() method.
*/
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
public void testHeadSet(String description, NavigableSet navigableSet) {
assertThrows(() -> {
NavigableSet ns = navigableSet.headSet(null, false);
}, NullPointerException.class, description + ": Must throw NullPointerException for null element");
assertThrows(() -> {
NavigableSet ns = navigableSet.headSet(new Object(), true);
}, ClassCastException.class, description + ": Must throw ClassCastException for non-Comparable element");
NavigableSet ns = navigableSet.headSet("1", false);
assertEmptyNavigableSet(ns, description + ": Returned value is not empty navigable set.");
}
use of java.util.NavigableSet in project jdk8u_jdk by JetBrains.
the class EmptyNavigableSet method testTailSetRanges.
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
public void testTailSetRanges(String description, NavigableSet navigableSet) {
NavigableSet subSet = navigableSet.tailSet(BigInteger.ONE, true);
// same subset
subSet.tailSet(BigInteger.ONE, true);
// slightly smaller
NavigableSet ns = subSet.tailSet(BigInteger.ONE, false);
// slight exapansion
assertThrows(() -> {
ns.tailSet(BigInteger.ONE, true);
}, IllegalArgumentException.class, description + ": Expansion should not be allowed");
// much smaller
subSet.tailSet(isDescending(subSet) ? BigInteger.ZERO : BigInteger.TEN, false);
}
use of java.util.NavigableSet in project jdk8u_jdk by JetBrains.
the class EmptyNavigableSet method testheadSetRanges.
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
public void testheadSetRanges(String description, NavigableSet navigableSet) {
NavigableSet subSet = navigableSet.headSet(BigInteger.ONE, true);
// same subset
subSet.headSet(BigInteger.ONE, true);
// slightly smaller
NavigableSet ns = subSet.headSet(BigInteger.ONE, false);
// slight exapansion
assertThrows(() -> {
ns.headSet(BigInteger.ONE, true);
}, IllegalArgumentException.class, description + ": Expansion should not be allowed");
// much smaller
subSet.headSet(isDescending(subSet) ? BigInteger.TEN : BigInteger.ZERO, true);
}
use of java.util.NavigableSet in project voltdb by VoltDB.
the class PrepareShutdown method executePlanFragment.
@Override
public DependencyPair executePlanFragment(Map<Integer, List<VoltTable>> dependencies, long fragmentId, ParameterSet params, SystemProcedureExecutionContext context) {
if (fragmentId == PF_prepareShutdown) {
super.run(context);
VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
if (context.isLowestSiteId()) {
VoltDB.instance().setShuttingdown(true);
t.addRow(m_stat.getMzxid());
if (LOG.isDebugEnabled()) {
LOG.debug("@PrepareShutdown returning sigil " + ll(m_stat.getMzxid()));
}
}
return new DependencyPair.TableDependencyPair(DEP_prepareShutdown, t);
} else if (fragmentId == PF_prepareShutdownAggregate) {
NavigableSet<Long> uniqueTxnIds = new TreeSet<>();
for (VoltTable t : dependencies.get(DEP_prepareShutdown)) {
while (t.advanceRow()) {
uniqueTxnIds.add(t.getLong(0));
}
}
VoltTable t = new VoltTable(VoltSystemProcedure.STATUS_SCHEMA);
for (long zktxnid : uniqueTxnIds) {
t.addRow(zktxnid);
}
return new DependencyPair.TableDependencyPair(DEP_prepareShutdonwAggregate, t);
} else {
VoltDB.crashLocalVoltDB("Received unrecognized plan fragment id " + fragmentId + " in PrepareShutdown", false, null);
}
throw new RuntimeException("Should not reach this code");
}
use of java.util.NavigableSet in project voltdb by VoltDB.
the class TestCOWSortedMap method testKeySetDescendingIteratorOrder.
/**
* descending iterator of key set is inverse ordered
*/
public void testKeySetDescendingIteratorOrder() {
COWSortedMap map = map5();
NavigableSet s = map.navigableKeySet();
Iterator i = s.descendingIterator();
Integer last = (Integer) i.next();
assertEquals(last, five);
int count = 1;
while (i.hasNext()) {
Integer k = (Integer) i.next();
assertTrue(last.compareTo(k) > 0);
last = k;
++count;
}
assertEquals(5, count);
}
Aggregations