List of usage examples for java.util NavigableMap put
V put(K key, V value);
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);//from ww w . j av a2 s . com System.out.println(nav.higherKey("G")); }
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);//from w w w .j a v a2s.co m System.out.println(nav.lowerKey("G")); }
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);/*from w w w . ja v a2 s. c om*/ System.out.println(nav.ceilingEntry("B")); }
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);/*from www . j av a 2s. co m*/ System.out.println(nav.ceilingKey("B")); }
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);//from ww w .j a v a 2 s . c o m System.out.println(nav.floorKey("G")); }
From source file:NavigableMapDemo.java
public static void main(String[] args) { NavigableMap<Integer, String> map = new TreeMap<Integer, String>(); map.put(2, "two"); map.put(1, "one"); map.put(3, "three"); System.out.println("Original map: " + map + "\n"); Entry firstEntry = map.pollFirstEntry(); System.out.println("First entry: " + firstEntry); System.out.println("After polling the first entry: " + map + "\n"); Entry lastEntry = map.pollLastEntry(); System.out.println("Last entry:" + lastEntry); System.out.println("After polling last entry:" + map); }
From source file:Main.java
public static void main(String[] args) { NavigableMap<String, String> nMap = new TreeMap<>(); nMap.put("CSS", "style"); nMap.put("HTML", "mark up"); nMap.put("Oracle", "database"); nMap.put("XML", "data"); System.out.println("Navigable Map:" + nMap); Entry<String, String> lowerXML = nMap.lowerEntry("XML"); Entry<String, String> floorXML = nMap.floorEntry("XML"); Entry<String, String> higherXML = nMap.higherEntry("XML"); Entry<String, String> ceilingXML = nMap.ceilingEntry("XML"); System.out.println("Lower:" + lowerXML); System.out.println("Floor:" + floorXML); System.out.println("Higher:" + higherXML); System.out.println("Ceiling:" + ceilingXML); // Get the reverse order view of the map NavigableMap<String, String> reverseMap = nMap.descendingMap(); System.out.println("Navigable Map(Reverse Order):" + reverseMap); }
From source file:Main.java
public static void main(String[] args) { NavigableMap<Integer, String> nmap = new TreeMap<Integer, String>(); nmap.put(1, "this"); nmap.put(2, "is"); nmap.put(3, "a"); nmap.put(4, "test"); nmap.put(5, "."); System.out.println(nmap);// w w w . j a va 2 s . c o m System.out.println(nmap.subMap(4, true, 5, true).values()); nmap.subMap(1, true, 3, true).clear(); System.out.println(nmap); // wrap into synchronized SortedMap SortedMap<Integer, String> ssmap = Collections.synchronizedSortedMap(nmap); System.out.println(ssmap.subMap(4, 5)); System.out.println(ssmap.subMap(4, 5 + 1)); }
From source file:in.java
public static void main(String[] args) { NavigableMap<Integer, String> map = new TreeMap<Integer, String>(); map.put(2, "two"); map.put(1, "one"); map.put(3, "three"); System.out.println("Original map: " + map + "\n"); Entry firstEntry = map.pollFirstEntry(); System.out.println("First entry: " + firstEntry); System.out.println("After polling the first entry: " + map + "\n"); Entry lastEntry = map.pollLastEntry(); System.out.println("Last entry:" + lastEntry); System.out.println("After polling last entry:" + map); }
From source file:Main.java
public static void main(String[] args) { NavigableMap<String, Integer> navigableMap = new TreeMap<String, Integer>(); String[] letters = { "a", "b", "c" }; int[] ints = { 3, 2, 1 }; for (int i = 0; i < letters.length; i++) { navigableMap.put(letters[i], ints[i]); }/*w w w . j a v a2 s .co m*/ System.out.println("Map = " + navigableMap); System.out.println("Poll first entry: " + navigableMap.pollLastEntry()); }