Infolinks In Text Ads

Feb 12, 2011

NavigableSet Interface

NavigableSet Interface -
    NavigableSet Interface is very useful for searching strategics. NavigableSet Interface gives the functionality for closest search mechanism. NavigableSet may search less than, less than or equal, greater than or equal, and greater than through the lower, floor, ceiling, and higher methods.

There is a example -
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.concurrent.ConcurrentSkipListSet;
public class Test {
    public static void main(String[] args) {
            NavigableSet nSet = new ConcurrentSkipListSet();
            nSet.add("A");
            nSet.add("B");
            nSet.add("C");
            nSet.add("D");
            nSet.add("E");
            nSet.add("F");
           
            System.out.println(nSet.ceiling("B"));
            System.out.println(nSet.floor("B"));
            System.out.println(nSet.lower("B"));
            System.out.println(nSet.higher("B"));
            System.out.println("Iterate Descending order");
            Iterator it = nSet.descendingIterator();
            while(it.hasNext())
                System.out.println(it.next());
            System.out.println("Iterate Ascending order");
            Iterator it1 = nSet.iterator();
            while(it1.hasNext())
                System.out.println(it1.next());
    }
}

output will be :
B
B
A
C
Iterate Descending order
F
E
D
C
B
A
Iterate Ascending order
A
B
C
D
E
F

1 comment:

  1. hi welcome to this blog. really you have post an informative blog. it will be really helpful to many peoples. thank you for sharing this blog.
    java training in chennai

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...