Remove and SortedSet

Hi all,
I'm just trying to remove the first item from a sorted set yet for some reason I'm having no luck. Here's the code
public class Main
    static  private Comparator smallestDistanceo = new Comparator ()
        public int compare (Object v, Object u)
           return compare ((Integer) v, (Integer) u);
        public int compare (Integer v, Integer u)
            int results = v.intValue () -  u.intValue ();
            if(results == 0)
                return -1;
            else
                return results;
    static SortedSet test = new TreeSet (smallestDistanceo);
    public static void main (String[] args)
        test.add (new Integer(3));
        test.add (new Integer(1));
        test.add (new Integer(2));
        for(Iterator i = test.iterator (); i.hasNext ();)
            Integer curr=(Integer)i.next ();
            System.out.print (curr.intValue ());
        if(test.remove(first))
            System.out.print("\nRemoved\n");
        else
            System.out.print("\nNot Removed\n");
        for(Iterator i = test.iterator (); i.hasNext ();)
            Integer curr=(Integer)i.next ();
            System.out.print (curr.intValue ());
}Yet for some reason the list just keeps coming back with nothing removed.
I'm sure it just something simple but can't see it for the life of me. Any ideas?

Yet for some reason the list just keeps coming back with nothing
removed. I'm sure it just something simple but can't see it for the life
of me. Any ideas?Your Comparator is broken: even if two objects are equal, you
return -1 indicating that the left operand object is smaller than the right
operand object, iow: your comparator never treats two objects as equal.
Even more: if you populate your SortedSet with Integers, you
don't need a user supplied Comparator at all; Integers know perfectly
well how to compare themselves against other integers.
The solution is simple: remove your Comparator and let the built-in
Integer comparator do the rest together with the SortedSet.
kind regards,
Jos

Similar Messages

  • I have songs on my iPhone 6 that I can't remove and when I plug into iTunes and go to "Summary" and "On This Device" the songs don't show up but they are on my phone. How do I remove them? Not even sure how they got on actually.

    I have songs on my iPhone 6 that I can't remove and when I plug into iTunes and go to "Summary" and "On This Device" the songs don't show up but they are on my phone. How do I remove them? Not even sure how they got on actually since I have a iTouch and keep all my music there. HELP!!

    Have you tried deleting the songs from Settings?
    Settings -> General -> Usage -> Manage Storage (not the iCloud link!) -> Music and then click Edit to enable you to be able to delete.

  • What's difference between JPanel.remove(); and JPanel = null

    nice day,
    how can remove JPanel (including its JComponents), safe way, can you explain the difference between JPanel.remove () and JPanel = null,
    1/ because if JPanel does not contain any static JComponents
    2/ or any reference to static objects,
    then works as well as JPanel.remove or JPanel = null,
    or what and why preferred to avoid some action (to avoid to remove or to avoid to null)

    mKorbel wrote:
    nice day,
    how can remove JPanel (including its JComponents), safe way, can you explain the difference between JPanel.remove () and JPanel = null, Remove the JPanel from the container it was part of and make sure you do not keep any references to it from your own classes. Don't make it any more difficult than it has to be.

  • Itunes stops working and I get an error message "APPCRASH" when I try to play a downloaded TV show. I have udated Itunes and removed and reinstalled quicktime.

    When I try to play a downloaded TV show, itunes stops working and I get a error message "APPCRASH". I have updated itunes and removed and reinstalled quicktime.

    Open your QuickTime control panel (either via the Control panels, or by going "Edit > Preferences > QuickTime Preferences" in the Quicktime Player). In the Advanced tab, uncheck Enable Direct3D video acceleration:
    ... and click OK.
    Quit the QuickTime Player if you have it open. Restart the PC and try watching the videos in iTunes again. Do they play now?

  • Macbook Pro won't start up after removing and putting back battery

    One week ago I spilled two drops (literally) of water on the drag pad of my MacBook Pro (model A1278). Some of this water went down the top edge of the drag pad. Since this happened, the cursor as either not been been responding at all to my drag pad, or it has been behaving very eratically, as well as this, over the last couple of months since buying this MacBook, there has been an abnormal amount of dust in the air in the house due to some building work going on here. This being so, I decided to follow a video tutorial in you tube on how to remove and clean the drag pad. This involved getting access to the laptop by unscrewing the back, unscrewing and disconnecting the battery, then unscrewing and disconnecting the drag pad, so this it could be handled and cleaned. I followed the video to the letter, taking great care. I cleaned the drag pad as instructed, and replaced it. I did the same thing with the battery. All screws and the two simple 'plug in' connections for both the drag pad and battery have been replaced smoothly and exactly as I found them. but after putting the back panel on the MacBook, it will not turn on. It will not power up, either by the battery alone, or by using the mains power lead. There is a green light showing on the power lead input, but it is nowhere near as bright as it usually is. So I have gone from having a poorly functioning drag pad, to now having a MacBook Pro which won't even turn on! I have no idea what has happened. Please can anyone help? Thanks.

    So are you saying that it will not boot from the OSX installation disk?
    It might be worth trying an SMC reset as described here:
    http://support.apple.com/kb/HT1411?locale=en_GB

  • Picks/Rejects dissappears after remove and reimport

    I have a mayor issue.
    My catalog has grown to inhuman size. =(
    So I tried to remove (not delete) some of the pictures/folders. Where I have a lot of Picks/Rejects, star ratings bla bla bla.
    So far so good.
    The problem comes, when i Reimport the files - then there are no.. I mean NO Picks/Rejects, only the star-ratings comes back up... sometimes!
    Today I tried this:
    New machine.
    New OS (snowleopard server)
    New LR install
    Reboot
    New catalog
    Force metadata save
    Check off Autosave metadata to catalog
    Update DNG Previews and Metadata, before, after, before and after.
    So far NO luck!
    HELP!

    Thanks man! Why didn't you tell me that a week ago!? =)
    You didn't ask a week ago. What was the question, anyway?
    How do I get around it then?
    Get around what? Since the title includes the text "remove and reimport", you should know that "remove and reimport" is almost always a bad idea. If you are going to keep a photo, I recommend you keep it in your Lightroom Library Module.
    My companion puts a catalog with every shoot, but that will take forever for me! Is there another way, but the hard way? Don't know about 200k pics, but too much to smile about, just by thinking of them!
    I don't know what "My companion puts a catalog..." means. I also don't understand what you mean by "don't know about 200k pics" ... what don't you know?
    Can someone point me to a super workflow routine, so things like this don't reappear!?
    Pronouns should have clear antecedents. I will guess that the word "this" in your sentence refers to the problem you had when you removed photos and reimported. I have already explained, don't reimport ... it is never a good idea. My workflow is very simple, and causes me no problems whatsoever. 1) The photos are Imported into Lightroom from the camera card to a folder named by the photo capture date. 2) I religiously apply keywords and captions to my photos; I make collections as needed. 3) I edit my photos in  the Lightroom Develop module, and I only use other editors if absolutely necessary. That's it; that's the entire workflow. I never remove and reimport. I never move my photos from one folder to another. It doesn't get any simpler than that, and it works well for me.

  • I have to remove and reinstall Flash Player 11.3 everyday! How can I fix it?

    I use Firefox and IE. Everyday I have to remove and reinstall flash player to be able to use it. Every day I receive the message that I don't have F player installed and I have to download it. I check add-ons and I can't find it there but it's installed in program,s and features in my control panel. I'm usin win 7 32-Bit and I always download the latest 11.3 F player. I'm tired of going through the same process everyday! BTW, I delete all my cookies and browsing history every time I want to close my explorers. But it's not new I've always done that but the problem with the lawstest F player is quite recent since the first time I download F player 11.3! Please help me.

    It sounds like you might be running into a Windows permission issue, please try the instructions in this FAQ:
    How do I fix Windows permission problems with Flash Player?
    Thanks,
    Chris

  • I have tried removing and re-installing my itunes on my PC, but it just comes up with a message saying that the error: entry point not found. pleaseee help!

    My itunes was working perfectly and then i upgraded and now it doesn't open and all i get is an error message.
    Ive tried so many times removing and re-installing and it won't work.
    Someone please help me!
    I am a windows 8 user!

    The most thorough explanation of what needs to be done is in the user tip: https://discussions.apple.com/docs/DOC-6562

  • I downloaded newest itunes version and it would not install properly and now i can't open it. i have removed and reinstalled several times. i get error 7 (windows error 126) something about apple mobile device failed to start. anybody having this problem.

    i downloaded newest itunes version and it would not install properly and now i can't open itunes. i have removed and reinstalled several times. i get error 7 (windows error 126) something about apple mobile device failed to start. what can i do to fix this problem besides restoring system to an earlier date

    Try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • I updated Firefox and now it will not open at all. The hourglass shows that it's working but then nothing. I went to add/remove and removed mozilla and reinstalled it and still the same thing. It worked fine before I updated.

    I updated Firefox and now it will not open at all. The hourglass shows that it's working but then nothing. I went to add/remove and removed mozilla and reinstalled it and still the same thing. It worked fine before I updated. Now I can't even remove the program at all. Why is this happening?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    Create a new profile as a test to check if your current profile is causing the problems.
    See "Basic Troubleshooting: Make a new profile":
    *https://support.mozilla.com/kb/Basic+Troubleshooting#w_8-make-a-new-profile
    There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins" in case there are still problems.
    If that new profile works then you can transfer some files from the old profile to that new profile, but be careful not to copy corrupted files.
    See:
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • How do I sync my old iPhone 5 to a new laptop PC without losing any iPhone data? The "remove and sync?" option looks like it will leave me with zero data on the iPhone!

    how do I sync my iPhone 5 to a new Toshiba laptop PC without losing any iPhone data? The "remove and sync?" option looks like it will leave me with zero data on the iPhone!

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • Is ther a way to speed up a Mac? Mine has gotten slower and slower over time.  When memory comes close to full would that have an effect on performance? Is there a way to determine unused programs/software to remove and free space?

    Is there a way to speed up a Mac (similar to de-fragging on a PC)? Mine has gotten slower and slower over time. 
    When memory/disc comes close to full would that have an effect on performance? How should I determine what programs/software to remove and free space?

    Things You Can Do To Resolve Slow Downs
    If your computer seems to be running slower here are some things you can do:
    Start with visits to:     OS X Maintenance - MacAttorney;
                                      The X Lab: The X-FAQs;
                                      The Safe Mac » Mac Performance Guide;
                                      The Safe Mac » The myth of the dirty Mac;
                                      Mac maintenance Quick Assist.
    Boot into Safe Mode then repair your hard drive and permissions:
    Repair the Hard Drive and Permissions Pre-Lion
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    Repair the Hard Drive - Lion/Mountain Lion/Mavericks
    Boot to the Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the Utilites Menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD disk icon and click on the arrow button below.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported, then click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu. Select Restart from the Apple menu.
    Restart your computer normally and see if this has helped any. Next do some maintenance:
    For situations Disk Utility cannot handle the best third-party utility is Disk Warrior;  DW only fixes problems with the disk directory, but most disk problems are caused by directory corruption; Disk Warrior 4.x is now Intel Mac compatible.
    Note: Alsoft ships DW on a bootable DVD that will startup Macs running Snow Leopard or earlier. It cannot start Macs that came with Lion or later pre-installed, however, DW will work on those models.
    Suggestions for OS X Maintenance
    OS X performs certain maintenance functions that are scheduled to occur on a daily, weekly, or monthly period. The maintenance scripts run in the early AM only if the computer is turned on 24/7 (no sleep.) If this isn't the case, then an excellent solution is to download and install a shareware utility such as Macaroni, JAW PseudoAnacron, or Anacron that will automate the maintenance activity regardless of whether the computer is turned off or asleep.  Dependence upon third-party utilities to run the periodic maintenance scripts was significantly reduced since Tiger.  These utilities have limited or no functionality with Snow Leopard or later and should not be installed.
    OS X automatically defragments files less than 20 MBs in size, so unless you have a disk full of very large files there's little need for defragmenting the hard drive.
    Helpful Links Regarding Malware Protection
    An excellent link to read is Tom Reed's Mac Malware Guide.
    Also, visit The XLab FAQs and read Detecting and avoiding malware and spyware.
    See these Apple articles:
              Mac OS X Snow Leopard and malware detection
              OS X Lion- Protect your Mac from malware
              OS X Mountain Lion- Protect your Mac from malware
              About file quarantine in OS X
    If you require anti-virus protection I recommend using VirusBarrier Express 1.1.6 or Dr.Web Light both from the App Store. They're both free, and since they're from the App Store, they won't destabilize the system. (Thank you to Thomas Reed for these recommendations.)
    Troubleshooting Applications
    I recommend downloading a utility such as TinkerTool System, OnyX, Mavericks Cache Cleaner, or Cocktail that you can use for removing old log files and archives, clearing caches, etc. Corrupted cache, log, or temporary files can cause application or OS X crashes as well as kernel panics.
    If you have Snow Leopard or Leopard, then for similar repairs install the freeware utility Applejack.  If you cannot start up in OS X, you may be able to start in single-user mode from which you can run Applejack to do a whole set of repair and maintenance routines from the command line.  Note that AppleJack 1.5 is required for Leopard. AppleJack 1.6 is compatible with Snow Leopard. Applejack does not work with Lion and later.
    Basic Backup
    For some people Time Machine will be more than adequate. Time Machine is part of OS X. There are two components:
    1. A Time Machine preferences panel as part of System Preferences;
    2. A Time Machine application located in the Applications folder. It is
        used to manage backups and to restore backups. Time Machine
        requires a backup drive that is at least twice the capacity of the
        drive being backed up.
    Alternatively, get an external drive at least equal in size to the internal hard drive and make (and maintain) a bootable clone/backup. You can make a bootable clone using the Restore option of Disk Utility. You can also make and maintain clones with good backup software. My personal recommendations are (order is not significant):
      1. Carbon Copy Cloner
      2. Get Backup
      3. Deja Vu
      4. SuperDuper!
      5. Synk Pro
      6. Tri-Backup
    Visit The XLab FAQs and read the FAQ on backup and restore.  Also read How to Back Up and Restore Your Files. For help with using Time Machine visit Pondini's Time Machine FAQ for help with all things Time Machine.
    Referenced software can be found at MacUpdate.
    Additional Hints
    Be sure you have an adequate amount of RAM installed for the number of applications you run concurrently. Be sure you leave a minimum of 10% of the hard drive's capacity as free space.
    Add more RAM. If your computer has less than 2 GBs of RAM and you are using OS X Leopard or later, then you can do with more RAM. Snow Leopard and Lion work much better with 4 GBs of RAM than their system minimums. The more concurrent applications you tend to use the more RAM you should have.
    Always maintain at least 15 GBs or 10% of your hard drive's capacity as free space, whichever is greater. OS X is frequently accessing your hard drive, so providing adequate free space will keep things from slowing down.
    Check for applications that may be hogging the CPU:
    Pre-Mavericks
    Open Activity Monitor in the Utilities folder.  Select All Processes from the Processes dropdown menu.  Click twice on the CPU% column header to display in descending order.  If you find a process using a large amount of CPU time (>=70,) then select the process and click on the Quit icon in the toolbar.  Click on the Force Quit button to kill the process.  See if that helps.  Be sure to note the name of the runaway process so you can track down the cause of the problem.
    Mavericks and later
    Open Activity Monitor in the Utilities folder.  Select All Processes from the View menu.  Click on the CPU tab in the toolbar. Click twice on the CPU% column header to display in descending order.  If you find a process using a large amount of CPU time (>=70,) then select the process and click on the Quit icon in the toolbar.  Click on the Force Quit button to kill the process.  See if that helps.  Be sure to note the name of the runaway process so you can track down the cause of the problem.
    Often this problem occurs because of a corrupted cache or preferences file or an attempt to write to a corrupted log file.

  • How do I find out who is attached to my sharing of my account and remove and add someone? Is 5 devices the limit?

    Devices sharing is 5?
    Where do I go to remove and add a devic

    Hey 1980justme!
    I have an article for you that can help you address this question:
    iTunes Store: Authorize or deauthorize your Mac or PC
    http://support.apple.com/kb/ht1420
    Thanks for coming to the Apple Support Communities!
    Regards,
    Braden

  • I am getting the following error message when I try to import photos into iPhoto from my camera: "/private/var/folders/GB/GBl4wh8-ELqUVMI5dO-ryU   TI/-Tmp-/iPhoto/DSCF2033.JPG".  Have already tried removing and reinstalling iPhoto to no avail.

    I am getting the following error message when I try to import photos into iPhoto from my camera: "/private/var/folders/GB/GBl4wh8-ELqUVMI5dO-ryU   TI/-Tmp-/iPhoto/DSCF2033.JPG".  Have already tried removing and reinstalling iPhoto to no avail.

    Does this happen if you try to Import to Library within iPhoto, or is it when you connect your camera (and which is set to automatically use iPhoto) that this error message occurs?
    If you open Image Capture > Preferences is iPhoto selected as the choice when a camera is connected?

  • My ipod touch 4g does not show in Windows 7 or itunes.  I've removed and reinstalled itunes, stopped and started apple mobile services and changed out cables.  Ipod is charging when connected.  I've also done a complete rollback to factory defaults.

    My ipod touch 4g does not show in Windows 7 or itunes, I've removed and reinstalled Itunes.  I've done a factory default, and I've changed out cables. The ipod shows connected but does not show.

    Did you remove and reinstall all the Apple software by:
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    Run this to see if it helps determine the cause
    iTunes for Windows: Device Sync Tests
    Try on another computer to help determine if you have an iPod or computer problem'
    Last, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
      Apple Retail Store - Genius Bar

Maybe you are looking for