Results 1 to 5 of 5
  1. #1
    ninoid is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default SortedSet and Collections.binarySearch

    hello everyone...

    I created my type which implements Comparable like
    public class Key implements Comparable{
    ...
    }

    and i added couple of keys in my sorted set

    SortedSet<Key> keys = new TreeSet<Key>();
    keys.add(new Key(...));
    keys.add(new Key(...));
    keys.add(new Key(...));

    when i try to binarysearch my sorted set like Collections.binarySearch(keys, new Key());
    i have error message:

    The method binarySearch(List<? extends Comparable<? super T>>, T) in the type Collections is not applicable for the arguments (SortedSet<Key>, Key)

    Can anyone explicitly write how to invoke binarySearch for theese types without error message...

    Thanks

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

  3. #3
    ninoid is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    I want to find answer as soon as possible.
    It does not mean anything bad...
    Sorry

  4. #4
    ninoid is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    Ok, people...
    Sorry for my cross thread...

    I do not want to hurt anybody but can someone shut discussion for this thread?

  5. #5
    ninoid is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    I found solution with SortedMap instead SortedSet...
    Thanks

Similar Threads

  1. Collections
    By Cbani in forum New To Java
    Replies: 3
    Last Post: 02-16-2010, 03:46 PM
  2. Replies: 4
    Last Post: 02-13-2009, 08:42 AM
  3. Collections Help
    By Dr Gonzo in forum New To Java
    Replies: 0
    Last Post: 12-07-2008, 10:15 PM
  4. Use different comparator for SortedSet
    By linus_k in forum New To Java
    Replies: 0
    Last Post: 11-21-2008, 03:46 PM
  5. Performance Of Collections
    By thomasprabu in forum Advanced Java
    Replies: 0
    Last Post: 01-05-2008, 12:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •