import java.util.*;
public class test
{
    public static void main(String[] args)
    {
	Abcast ab;
	CoreMessage cm=new CoreMessage(1,"Ram Ram Tukaram");
	Compare c=new Compare();
	TreeMap v=new TreeMap(c);
	//for(int i=0;i<100;i++)
	//  v.add(new Message(-1,-1,-1,-1,new Abcast(cm,0),-1));
	//System.out.println(v.size());
	Message m1=new Message(0,0,1,0,new Abcast(cm,0),1);
    	Message m2=new Message(0,0,2,0,new Abcast(cm,0),2);
	Message m3=new Message(1,0,1,0,new Abcast(cm,0),1);
	Message m4=new Message(1,0,2,0,new Abcast(cm,0),2);
	//System.out.println((""+(m2.getmessagesource()+m2.getmessageid())).hashCode());
	//v.add("mithun");
	v.put((""+m1.getmessagesource()+"#"+m1.getmessageid()).hashCode(),m1);
	v.put((""+m2.getmessagesource()+"#"+m2.getmessageid()).hashCode(),m2);
	v.put((""+m3.getmessagesource()+"#"+m3.getmessageid()).hashCode(),m3);
	v.put((""+m4.getmessagesource()+"#"+m4.getmessageid()).hashCode(),m4);
	//System.out.println(v);
	Collections.sort(v,c);
	for(int i=0;i<4;i++)
	    {
		m1=(Message)v.lastElement();
		System.out.println(m1.getmessagesource()+"  "+m1.getmessageobject().getmessagepriority());
		v.remove(v.lastElement());
	    }


    }
}
