Hi. I'm having some problems with TreeMap constructors. I have a class with 2 TreeMaps<Client>
inside it. A tree sorted by name and another sorted by number.(client class : String name, int number, ...)
private TreeMap<String, Client> nameTree;
private TreeMap<Integer, Client> numberTree;
How do i build the constructors for this class? So far i wrote this:
public ManagerTreeMap(){
nameTree = new TreeMap<String, Client>(new StringComparator());
numberTree = new TreeMap<Integer, Client>(new IntegerComparator());
}
My major problem is the construtor "TreeMap(Comparator c)". Can i write two comparators? if not what do i have to do?
public ManagerTreeMap(Comparator<String> cp){
nameTree = new TreeMap<String, Client>(cp);
}
public ManagerTreeMap(Comparator<Integer> cpt){
nameTree = new TreeMap<Integer, Client>(cpt);
}