List of usage examples for java.util TreeMap TreeMap
public TreeMap()
From source file:Main.java
public static void main(String[] args) { TreeMap<String, String> treeMap = new TreeMap<String, String>(); treeMap.put("1", "One"); treeMap.put("3", "Three"); treeMap.put("2", "Two"); treeMap.put("5", "Five"); treeMap.put("4", "Four"); SortedMap sortedMap = treeMap.headMap("3"); System.out.println("Head Map Contains : " + sortedMap); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> db = new TreeMap<Integer, String>(); db.put(1000, "1000"); db.put(1011, "1011"); db.put(1102, "1102"); db.put(2023, "2023"); db.put(2034, "2034"); TreeMap<Integer, String> db2 = new TreeMap<Integer, String>(db); System.out.println(db2);/*from w w w . j ava 2 s . c om*/ }
From source file:Main.java
public static void main(String[] args) { TreeMap<String, String> treeMap = new TreeMap<String, String>(); treeMap.put("1", "One"); treeMap.put("3", "Three"); treeMap.put("2", "Two"); treeMap.put("5", "Five"); treeMap.put("4", "Four"); SortedMap sortedMap = treeMap.tailMap("2"); System.out.println("Tail Map Contains : " + sortedMap); }
From source file:Main.java
public static void main(String[] args) { TreeMap<String, String> treeMap = new TreeMap<String, String>(); treeMap.put("1", "One"); treeMap.put("2", "Two"); treeMap.put("3", "Three"); treeMap.put("4", "Four"); treeMap.put("5", "Five"); SortedMap sortedMap = treeMap.subMap("2", "5"); System.out.println("SortedMap Contains : " + sortedMap); }
From source file:Main.java
public static void main(String[] args) { Map<Character, Integer> map = new TreeMap<>(); String blah = "aaaabbbbddd"; for (int i = 0; i < blah.length(); i++) { char c = blah.charAt(i); if (!map.containsKey(c)) { map.put(c, 1);/*from ww w . java 2 s . c om*/ } else { map.put(c, (map.get(c) + 1)); } } for (Map.Entry<Character, Integer> entry : map.entrySet()) { System.out.print(entry.getKey() + "" + entry.getValue()); } }
From source file:Main.java
public static void main(String[] args) { SortedMap<String, Integer> sortedMap = new TreeMap<String, Integer>(); sortedMap.put("A", 1); sortedMap.put("B", 2); sortedMap.put("C", 3); sortedMap.put("D", 4); sortedMap.put("E", 5); sortedMap.put("java2s", 6); System.out.println(sortedMap.entrySet()); }
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 . ja v a 2 s.c o m*/ System.out.println(nav.floorEntry("G")); }
From source file:Main.java
public static void main(String[] args) { SortedMap<String, Integer> sortedMap = new TreeMap<String, Integer>(); sortedMap.put("A", 1); sortedMap.put("B", 2); sortedMap.put("C", 3); sortedMap.put("D", 4); sortedMap.put("E", 5); sortedMap.put("java2s", 6); System.out.println(sortedMap.firstKey()); }
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 a 2 s .c o m*/ 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 ava2 s . c o m*/ System.out.println(nav.lowerKey("G")); }