/* Because it is a binary tree, the general search time complexity is O (lg (n )),
Of course, this efficiency is not as efficient as hashmap.
However, treemap is more powerful than hashmap,
If no sorting is required, treemap is not used,
If sorting is required, hashmap cannot be competent. Of course, it must use treemap. It can be used as a sub-map.
Therefore, this is an applicable issue and cannot be compared.
*/
Import java. util .*;
Class treesettest2
{
Public static void main (string [] ARGs)
{
Treeset <treesettest2> TS = new treeset <treesettest2> (New treesettest2comparator ());
Pipeline SC = new pipeline (system. In );
Int quit;
System. Out. println ("input numbers, to quit, input 0 ");
While (quit = SC. nextint ())! = 0)
TS. Add (New treesettest2 (quit ));
For (treesettest2 TST: TS)
System. Out. println (TST. getint ());
}
Int I;
Treesettest2 (int I ){
This. I = I;
}
Int getint (){
Return I;
}
}
Class TreeSetTest2Comparator implements Comparator <TreeSetTest2> // if you do not use generics, a warning will be reported during compilation.
{
/* Public int compare (Object object1, Object object2 ){
Return-(TreeSetTest2) object1). I-(TreeSetTest2) object2). I );
}
*/
Public int compare (TreeSetTest2 tst1, TreeSetTest2 tst2 ){
Return-(tst2. I-tst1. I );
}
}