List of usage examples for java.util NavigableMap higherKey
K higherKey(K key);
From source file:Main.java
public static void main(String args[]) { Calendar now = Calendar.getInstance(); Locale locale = Locale.getDefault(); Map<String, Integer> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale); NavigableMap<String, Integer> nav = new TreeMap<String, Integer>(names); System.out.printf("Whole list:%n%s%n", nav); System.out.printf("Key higher after Sunday: %s%n", nav.higherKey("Sunday")); }
From source file:Main.java
public static void main(String args[]) { NavigableMap<String, String> nav = new TreeMap<String, String>(); nav.put("A", "a"); nav.put("B", "b"); nav.put("C", "c"); nav.put("D", "d"); nav.put("E", "e"); nav.put("F", "f"); System.out.println(nav);/*w w w .j a v a 2s . c om*/ System.out.println(nav.higherKey("G")); }
From source file:com.google.gwt.emultest.java.util.TreeMapTest.java
public void testHigherKey() { K[] keys = getSortedKeys();/*from w w w. j a va 2s.com*/ V[] values = getSortedValues(); NavigableMap<K, V> map = createNavigableMap(); // test with a single entry map map.put(keys[0], values[0]); assertEquals(null, map.higherKey(keys[0])); assertEquals(keys[0], map.higherKey(getLessThanMinimumKey())); // is it consistent with other methods assertEquals(map.keySet().toArray()[0], map.higherKey(getLessThanMinimumKey())); // test with two entry map map.put(keys[1], values[1]); assertEquals(keys[0], map.higherKey(getLessThanMinimumKey())); assertEquals(keys[1], map.higherKey(keys[0])); assertNull(map.higherKey(keys[1])); assertNull(map.higherKey(getGreaterThanMaximumKey())); try { map.higherKey(null); assertTrue("expected exception", useNullKey()); } catch (NullPointerException e) { assertFalse("unexpected NPE", useNullKey()); } map.clear(); assertNull(map.higherKey(keys[1])); assertNull(map.higherKey(null)); }
From source file:org.apache.cassandra.dht.tokenallocator.ReplicationAwareTokenAllocatorTest.java
private static double replicatedTokenOwnership(Token token, NavigableMap<Token, Unit> sortedTokens, ReplicationStrategy<Unit> strategy) { TestReplicationStrategy ts = (TestReplicationStrategy) strategy; Token next = sortedTokens.higherKey(token); if (next == null) next = sortedTokens.firstKey();//from ww w . ja va 2 s .c om return ts.replicationStart(token, sortedTokens.get(token), sortedTokens).size(next); }