1 16 package org.apache.commons.collections; 17 18 import java.util.Collection ; 19 import java.util.Comparator ; 20 import java.util.SortedMap ; 21 import java.util.TreeMap ; 22 23 34 public class TreeBag extends DefaultMapBag implements SortedBag { 35 36 39 public TreeBag() { 40 super(new TreeMap ()); 41 } 42 43 49 public TreeBag(Comparator comparator) { 50 super(new TreeMap (comparator)); 51 } 52 53 59 public TreeBag(Collection coll) { 60 this(); 61 addAll(coll); 62 } 63 64 public Object first() { 65 return ((SortedMap ) getMap()).firstKey(); 66 } 67 68 public Object last() { 69 return ((SortedMap ) getMap()).lastKey(); 70 } 71 72 public Comparator comparator() { 73 return ((SortedMap ) getMap()).comparator(); 74 } 75 76 } 77 | Popular Tags |