List of usage examples for java.util TreeMap put
public V put(K key, V value)
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); System.out.println("Getting tail map"); SortedMap<Integer, String> treemapincl = treemap.tailMap(3); System.out.println("Tail map values: " + treemapincl); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); System.out.println("Getting a portion of the map"); SortedMap<Integer, String> treemapincl = treemap.subMap(1, 5); System.out.println("Sub map values: " + treemapincl); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); System.out.println("Ceiling key entry for 4: " + treemap.ceilingKey(4)); System.out.println("Ceiling key entry for 5: " + treemap.ceilingKey(5)); System.out.println("Ceiling key entry for 7: " + treemap.ceilingKey(7)); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); System.out.println("Getting tail map"); SortedMap<Integer, String> treemapincl = treemap.tailMap(3, true); System.out.println("Tail map values: " + treemapincl); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); System.out.println("Getting collection from the map"); Collection<String> coll = treemap.values(); System.out.println("Value of the collection: " + coll); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); System.out.println("Getting a portion of the map"); NavigableMap<Integer, String> treemapincl = treemap.subMap(1, true, 3, true); System.out.println("Sub map values: " + treemapincl); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); // polling first entry System.out.println("Value before poll: " + treemap); System.out.println("Value returned: " + treemap.pollFirstEntry()); System.out.println("Value after poll: " + treemap); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); // polling last entry System.out.println("Value before poll: " + treemap); System.out.println("Value returned: " + treemap.pollLastEntry()); System.out.println("Value after poll: " + treemap); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); // putting values in navigable set NavigableSet nset = treemap.descendingKeySet(); System.out.println("Checking value"); System.out.println("Navigable set values: " + nset); }
From source file:Main.java
public static void main(String[] args) { TreeMap<Integer, String> treemap = new TreeMap<Integer, String>(); // populating tree map treemap.put(2, "two"); treemap.put(1, "one"); treemap.put(3, "three"); treemap.put(6, "six"); treemap.put(5, "from java2s.com"); // putting values in navigable map NavigableMap nmap = treemap.descendingMap(); System.out.println("Checking value"); System.out.println("Navigable map values: " + nmap); }