List of usage examples for java.util NavigableMap keySet
Set<K> keySet();
From source file:com.rockhoppertech.music.midi.js.MIDITrack.java
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Track Name:").append(name).append('\n'); // if (this.description != null || this.description.equals("")) // sb.append("Description:").append(this.description).append('\n'); // sb.append("Instrument:").append(this.gmpatch).append('\n'); sb.append("Instrument:").append(this.instrument).append('\n'); if (this.notes.size() > 0) { for (MIDINote n : notes) { sb.append(n).append('\n'); }/*from w w w . jav a2 s. c o m*/ } else { sb.append("no notes").append('\n'); } if (this.events.size() > 0) { sb.append("events").append('\n'); for (MIDIEvent n : events) { sb.append(n.toReadableString()).append('\n'); sb.append(n.toString()).append('\n'); } } else { sb.append("no events").append('\n'); } NavigableMap<Double, KeySignature> keys = this.getKeySignatures(); for (Double time : keys.keySet()) { KeySignature key = keys.get(time); sb.append("Key: ").append(key.getDisplayName()).append(" at beat ").append(time).append('\n'); } NavigableMap<Double, TimeSignature> timeSigs = this.getTimeSignatures(); for (Double time : timeSigs.keySet()) { TimeSignature ts = timeSigs.get(time); sb.append("Time signature: ").append(ts.getDisplayName()).append(" at beat ").append(time).append('\n'); } NavigableMap<Double, Integer> tempoMap = this.getTempoMap(); for (Double time : tempoMap.keySet()) { Integer tempo = tempoMap.get(time); sb.append("Tempo: ").append(tempo).append(" at beat ").append(time).append('\n'); } return sb.toString(); }
From source file:com.google.gwt.emultest.java.util.TreeMapTest.java
public void testFirstEntry() { K[] keys = getSortedKeys();// ww w.ja v a 2s . c o m V[] values = getSortedValues(); NavigableMap<K, V> map = createNavigableMap(); // test with a single entry map map.put(keys[0], values[0]); assertEquals(keys[0], map.firstEntry().getKey()); // is it consistent with other methods assertEquals(map.keySet().toArray()[0], map.firstEntry().getKey()); assertEquals(keys[0], map.lastEntry().getKey()); assertEquals(map.lastEntry().getKey(), map.firstEntry().getKey()); // test with two entry map map.put(keys[1], values[1]); Entry<K, V> entry = map.firstEntry(); verifyEntry(entry); assertEquals(keys[0], entry.getKey()); assertFalse(keys[1].equals(map.firstEntry().getKey())); // is it consistent with other methods assertEquals(map.keySet().toArray()[0], map.firstEntry().getKey()); assertFalse(keys[0].equals(map.lastEntry().getKey())); assertFalse(map.lastEntry().getKey().equals(map.firstEntry().getKey())); map.clear(); assertNull(map.firstEntry()); }
From source file:com.google.gwt.emultest.java.util.TreeMapTest.java
public void testLastEntry() { K[] keys = getSortedKeys();//w w w . jav a 2 s .co m V[] values = getSortedValues(); NavigableMap<K, V> map = createNavigableMap(); // test with a single entry map map.put(keys[0], values[0]); assertEquals(keys[0], map.lastEntry().getKey()); // is it consistent with other methods assertEquals(map.keySet().toArray()[0], map.lastEntry().getKey()); assertEquals(keys[0], map.firstEntry().getKey()); assertEquals(values[0], map.firstEntry().getValue()); assertEquals(map.firstEntry().getKey(), map.lastEntry().getKey()); // test with two entry map map.put(keys[1], values[1]); assertEquals(keys[1], map.lastEntry().getKey()); assertFalse(keys[0].equals(map.lastEntry().getKey())); // is it consistent with other methods assertEquals(map.keySet().toArray()[1], map.lastEntry().getKey()); Entry<K, V> entry = map.firstEntry(); verifyEntry(entry); assertEquals(keys[0], entry.getKey()); assertFalse(map.firstEntry().getKey().equals(map.lastEntry().getKey())); map.clear(); assertNull(map.lastEntry()); }
From source file:com.google.gwt.emultest.java.util.TreeMapTest.java
public void testHigherKey() { K[] keys = getSortedKeys();//from www. j av a2 s . c o m 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:com.google.gwt.emultest.java.util.TreeMapTest.java
public void testCeilingKey() { K[] keys = getSortedKeys();/*from ww w .j a va 2 s. co m*/ V[] values = getSortedValues(); NavigableMap<K, V> map = createNavigableMap(); // test with a single entry map map.put(keys[0], values[0]); assertEquals(keys[0], map.ceilingKey(keys[0])); assertEquals(keys[0], map.ceilingKey(getLessThanMinimumKey())); // is it consistent with other methods assertEquals(map.keySet().toArray()[0], map.ceilingKey(getLessThanMinimumKey())); // test with two entry map map.put(keys[1], values[1]); assertEquals(keys[0], map.ceilingKey(getLessThanMinimumKey())); assertEquals(keys[0], map.ceilingKey(keys[0])); assertEquals(keys[1], map.ceilingKey(keys[1])); assertNull(map.ceilingKey(getGreaterThanMaximumKey())); try { map.ceilingKey(null); assertTrue("expected exception", useNullKey()); } catch (NullPointerException e) { assertFalse("unexpected NPE", useNullKey()); } map.clear(); assertNull(map.ceilingKey(keys[1])); assertNull(map.ceilingKey(null)); }
From source file:com.google.gwt.emultest.java.util.TreeMapTest.java
public void testDescendingKeySet() { K[] keys = getSortedKeys();// ww w. j a va 2 s.co m V[] values = getSortedValues(); NavigableMap<K, V> map = createNavigableMap(); map.put(keys[0], values[0]); NavigableSet<K> keySet = map.descendingKeySet(); _assertEquals(keySet, map.descendingKeySet()); map.put(keys[1], values[1]); map.put(keys[2], values[2]); _assertEquals(reverseCollection(keySet), keySet); _assertEquals(map.keySet(), keySet.descendingSet()); }
From source file:com.google.gwt.emultest.java.util.TreeMapTest.java
public void testCeilingEntry() { K[] keys = getSortedKeys();/*www .j a va 2 s. c om*/ V[] values = getSortedValues(); NavigableMap<K, V> map = createNavigableMap(); // test with a single entry map map.put(keys[0], values[0]); assertEquals(keys[0], map.ceilingEntry(keys[0]).getKey()); assertEquals(values[0], map.ceilingEntry(keys[0]).getValue()); assertEquals(keys[0], map.ceilingEntry(getLessThanMinimumKey()).getKey()); // is it consistent with other methods assertEquals(map.keySet().toArray()[0], map.ceilingEntry(getLessThanMinimumKey()).getKey()); // test with two entry map map.put(keys[1], values[1]); assertEquals(keys[0], map.ceilingEntry(getLessThanMinimumKey()).getKey()); Entry<K, V> entry = map.ceilingEntry(keys[0]); verifyEntry(entry); assertEquals(keys[0], entry.getKey()); assertEquals(keys[1], map.ceilingEntry(keys[1]).getKey()); assertEquals(values[1], map.ceilingEntry(keys[1]).getValue()); assertNull(map.ceilingEntry(getGreaterThanMaximumKey())); }
From source file:com.google.gwt.emultest.java.util.TreeMapTest.java
public void testHigherEntry() { K[] keys = getSortedKeys();/*from ww w . j av a 2 s .c o m*/ V[] values = getSortedValues(); NavigableMap<K, V> map = createNavigableMap(); // test with a single entry map map.put(keys[0], values[0]); assertNull(map.higherEntry(keys[0])); assertEquals(keys[0], map.higherEntry(getLessThanMinimumKey()).getKey()); assertEquals(values[0], map.higherEntry(getLessThanMinimumKey()).getValue()); // is it consistent with other methods assertEquals(map.keySet().toArray()[0], map.higherEntry(getLessThanMinimumKey()).getKey()); // test with two entry map map.put(keys[1], values[1]); assertEquals(keys[0], map.higherEntry(getLessThanMinimumKey()).getKey()); Entry<K, V> entry = map.higherEntry(keys[0]); verifyEntry(entry); assertEquals(keys[1], entry.getKey()); assertEquals(values[1], entry.getValue()); assertNull(map.higherEntry(keys[1])); assertNull(map.higherEntry(getGreaterThanMaximumKey())); try { map.higherEntry(null); assertTrue("expected exception", useNullKey()); } catch (NullPointerException e) { assertFalse("unexpected NPE", useNullKey()); } map.clear(); assertNull(map.higherEntry(keys[1])); assertNull(map.higherEntry(null)); }
From source file:com.google.gwt.emultest.java.util.TreeMapTest.java
public void testLowerKey() { K[] keys = getSortedKeys();/* w w w. j a v a 2 s . c o m*/ V[] values = getSortedValues(); NavigableMap<K, V> map = createNavigableMap(); // test with a single entry map map.put(keys[0], values[0]); assertNull(map.lowerKey(getLessThanMinimumKey())); assertNull(map.lowerKey(keys[0])); assertEquals(keys[0], map.lowerKey(keys[1])); assertEquals(keys[0], map.lowerKey(getGreaterThanMaximumKey())); // is it consistent with other methods assertEquals(map.keySet().toArray()[0], map.lowerKey(keys[1])); // test with two entry map map.put(keys[1], values[1]); assertNull(map.lowerKey(getLessThanMinimumKey())); assertNull(map.lowerKey(keys[0])); assertEquals(keys[0], map.lowerKey(keys[1])); assertEquals(keys[1], map.lowerKey(getGreaterThanMaximumKey())); try { map.lowerKey(null); assertTrue("expected exception", useNullKey()); } catch (NullPointerException e) { assertFalse("unexpected NPE", useNullKey()); } map.clear(); assertNull(map.lowerKey(keys[1])); assertNull(map.lowerKey(null)); }
From source file:com.google.gwt.emultest.java.util.TreeMapTest.java
public void testFloorKey() { K[] keys = getSortedKeys();//from w w w .ja v a 2 s.com V[] values = getSortedValues(); NavigableMap<K, V> map = createNavigableMap(); // test with a single entry map map.put(keys[0], values[0]); assertNull(map.floorKey(getLessThanMinimumKey())); assertEquals(keys[0], map.floorKey(keys[0])); assertEquals(keys[0], map.floorKey(keys[1])); assertEquals(keys[0], map.floorKey(getGreaterThanMaximumKey())); // is it consistent with other methods assertEquals(map.keySet().toArray()[0], map.floorKey(keys[1])); // test with two entry map map.put(keys[1], values[1]); assertNull(map.floorKey(getLessThanMinimumKey())); assertEquals(keys[0], map.floorKey(keys[0])); assertEquals(keys[1], map.floorKey(keys[1])); assertEquals(keys[1], map.floorKey(getGreaterThanMaximumKey())); try { map.floorKey(null); assertTrue("expected exception", useNullKey()); } catch (NullPointerException e) { assertFalse("unexpected NPE", useNullKey()); } map.clear(); assertNull(map.floorKey(keys[1])); assertNull(map.floorKey(null)); }