Is this right or wrong?

Here is an excerpt from API doc for the interface, java.util.Comparator,
Caution should be exercised when using a comparator capable of imposing an ordering inconsistent with equals to order a sorted set (or sorted map). Suppose a sorted set (or sorted map) with an explicit Comparator c is used with elements (or keys) drawn from a set S. If the ordering imposed by c on S is inconsistent with equals, the sorted set (or sorted map) will behave "strangely." In particular the sorted set (or sorted map) will violate the general contract for set (or map), which is defined in terms of equals.
For example, if one adds two keys a and b such that (a.equals((Object)b) && c.compare((Object)a, (Object)b) != 0) to a sorted set with comparator c, the second add operation will return false (and the size of the sorted set will not increase) because a and b are equivalent from the sorted set's perspective.
Is it right? Will the second add operation fail?
In my opinion, the sorted set performs ordering in terms of compare/compareTo method, while a set decides whether to accept or refuse a new element by equals method. If this is the case, then under the situation described in the API doc, a and b are NOT equivalent from the sorted set's prespective, thus a and b can both be added successfully. And only if this happened, we could say[i] total ordering inconsistent with equals could work well for sorted set, but breaks the general contract for the set.
I'm totally confused.

I think the API comment you mention got it backwards. Did you whip up an example
to test this yourself?
import java.util.*;
public class Example {
    public int compare; //used to define comparator
    public int equal;   //used to define equals
    public Example(int compare, int equal) {
        this.compare = compare;
        this.equal = equal;
    public boolean equals(Object o) {
        if (!(o instanceof Example))
            return false;
        return equal == ((Example)o).equal;
    public String toString() {
        return "(compare=" + compare + ", equal=" + equal + ")";
    public static class C implements Comparator {
        public int compare(Object o1, Object o2) {
            return ((Example)o1).compare - ((Example)o2).compare;
    public static void main(String[] args) throws Exception {
        C c = new C();
        Set s = new TreeSet(c);
        Example a = new Example(0, 0);
        Example b = new Example(1, 0);
        System.out.println("a.equals(b) = " + a.equals(b));
        System.out.println("c.compare(a,b) = " + c.compare(a,b));
        s.add(a);
        System.out.println("after adding a, s =" + s);
        s.add(b);
        System.out.println("after adding b, s =" + s);
}

Similar Messages

  • My iphone consumed  10GB data this what's wrong with my VPN kindly guide suitably moreover battery drain fast

    My iphone 5s consumed  10GB data this what's wrong with my VPN kindly guide suitably moreover battery drain fast

    The long backups seem to be related to the size of the apps you installed, not the number. That's why some people with multiple pages of apps experience fast backups. There does seem to be a bug with the current firmware that can cause a crash when doing app uploads and syncs. This bug seems to be exacerbated by having large and many apps.
    I was experiencing frequent crashes, but have no more - even with 70 apps installed - some of them large like the American Heritage Dictionary which is several hundred megabytes. I did the following:
    1. I set iTunes to NOT do autosyncs every time I plug in. This setting is in the Itunes preferences.
    2. I disabled the autobackups in iTunes for the iphone. I figured that if it did crash and it was going to take 2 hours to restore, why not just reload. The instructions are readily found using google search; it involves a command line setting. Anyway, the phone doesn't crash anymore since doing this.
    3. I no longer install apps using the iPhone. I first install the app in iTunes and the I manually sync it to the iphone. I avoid doing multiple installs at once; at least for the large apps. Right click on each app and get its info from within itunes. If it is large, it is going to take time to backup.
    4. I always first shut off the iphone and restart it before installing any apps in itunes. This clears any memory issues left behind from use.
    I am going to continue to do these procedures until Apple releases a fix for the bugs relating to the apps.
    As noted, since I took these steps, I have had no crashes. I was crashing at least once every 1-2 days before with the same or less number of apps. I too was a first gen iPhone user and was very frustrated with the 3G experience. Since doing the above, I am once again a very happy and productive iPhone 3G user. I know its a pain to do this, but the bugs will get fixed at some point. I would never go back to my old phones - they were just phones.

  • Formula column right or wrong

    hi frds
    i just want to know whether this formula colum in report builder is right or wrong
    function CF_1Formula return Number is
    X NUMBER;
    begin
    SELECT sum(ABS(nvl(TRAN.QUANTITY,0))) INTO X
    FROM RCV_TRANSACTIONS TRAN,RCV_SHIPMENT_HEADERS RCV,PO_LINES_ALL PL
    WHERE TRAN.TRANSACTION_TYPE ='RECEIVE' AND TRAN.PO_HEADER_ID = :PO_HEADER_ID
    AND TRAN.SHIPMENT_HEADER_ID = :SHIPMENT_HEADER_ID
    AND TRAN.SHIPMENT_HEADER_ID = RCV.SHIPMENT_HEADER_ID
    AND RCV.RECEIPT_NUM=:RECEIPT_NUM
    AND TRAN.ORGANIZATION_ID=:organization_id
    AND TRAN.PO_LINE_ID = PL.PO_LINE_ID
    and pl.item_id=:inventory_item_id;
    RETURN(X);
    end;

    right

  • Firefox, when clicked, said IMPORTANT update,pressed enter! But then download went on forever? I didn't trust it, so cancelled download- Right or wrong?? Thanks

    yes, when I pressed enter, the horizontal "tube" never quite filled up, if you know what I mean! I didn't recognise this format & it was taken so long (minutes) I thought it was fraudulent . . was I right or wrong???

    Do you memeber the complete wording of the error message?
    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iPod fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - If still not successful that indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar

  • Is there a cd making software like Jam 6.0.3 that will let you crossfade songs in a playlist that works on 10.7 or later OS? Sorry if this is the wrong place to post this.

    Is there a software app out there like Jam 6.0.3 that allows you to arrange and crossfade songs in a playlist that works on 10.7 or later OS? I have Jam on 10.6.8 now and it works great but it will not work on 10.7 and I need to upgrade the OS to run a new Drobo setup.
    Sorry if this is the wrong place to post this question please direct me to the right place.

    Hi, I'm not sure it does what you want, but only thing I can think of is Audacity...
    http://audacity.sourceforge.net/download/mac

  • I had version 3.5.2 and Firefox updated to version 17. Is this right?

    Hello-
    I am new to Firefox. I have it set to update automatically. I noticed it was updating to the latest version today, so I stayed and watched. I had version 3.5.2 (I am pretty sure) but the latest version it just updated to is version 17. Is this right? I am used to version going in order but from version 3.5.2 to 17? did something go wrong?

    Now your using Firefox 3.5.2 if you update, <br>
    Firsts it update to Firefox 4 and keeps going on and finally update firefox 17.<br><br>
    To avoid that, Download and Install it.
    <br>
    http://www.mozilla.org/en-US/firefox/new/
    <br>
    <br>
    Auto update - > http://mzl.la/LFolSf

  • Is there someone at Verizon that still cares about their customers and will help make this right??

    I have spent hours on two phone calls and a chat session regarding a billing discrepancy that is THE FAULT OF VERIZON and still no final resolution.  My bill is due in 3 days and I want this resolved now because I don't want to not pay a bill on time because it won't be corrected in time and then my credit rating will fall due to THE FAULT OF VERIZON.  I have been working on this problem for OVER TWO WEEKS and TWICE have been told that it was all set and that billing was being told to credit my account, yet STILL NO CREDIT HAS HAPPENED.  One rep gave me his email address so that I could follow up with him in case something went wrong with the credit.  I have emailed him and GUESS WHAT?  NO RESPONSE.  I have been a loyal Verizon customer for over 15 years with all bills always PAID ON TIME and THIS IS HOW I GET TREATED??   NOT FAIR.  This is so unlike me to write something like this in a forum, but I have had it after receiving THE WORST CUSTOMER SERVICE EVER.  WHAT AM I SUPPOSED TO DO NOW TO GET HELP?  Is no one at Verizon support HELD ACCOUNTABLE FOR VERIZON MISTAKES??  A VERIZON representative listened to what I needed for business travel and they gave me the added feature that they assured me would be what I needed, and apparently it wasn't right. Is it my fault that a Verizon representative does not know the right answers to how their features work and now I am expected to pay OVER $300 EXTRA BECAUSE OF THEIR MISTAKE?  When I take the advice of a Verizon rep I expect they know what they are talking about and that the advice is accurate.  APPARENTLY THIS ISN'T TRUE.
    Is there someone at Verizon that still cares about their customers and will help make this right??

    After ANOTHER call I may be on track to resolving this.  But WHY did it have to take several calls and chats over a two week period?  WHY did I have to become a mean person to the representative on the phone to finally get this (partially) straightened out?  Why does it need to come to that?  I really don't want to have to get mean and get myself worked up just to get a billing problem straightened out that is VERIZON'S fault.
    Verizon, please consider looking into your lack of proper customer support and make corrections.  Even though this may be resolved, After 15 years of being a Verizon customer I will be considering another carrier when my contract runs out and all due to this horrible customer service experience. 

  • Why have iTunes charged my account when I've got a £20 voucher on my account and the. Had to arrange a call back what was 2 days ago they called me back tonight then said the department was closed this is a wrong I want my money back!

    Why have iTunes charged my account when I've got a £20 voucher on my account and the. Had to arrange a call back what was 2 days ago they called me back tonight then the automated voice said the department was closed this is a wrong I want my money back! Or I'm gonna sell my iPad my kids iPods and iPhones mine and my wife's iPhones and the mac this is a **** take

    We are fellow users here on these forums, you are not talking to iTunes Support nor Apple.
    Were you buying content for yourself or gifting to another account ? If you were gifting content or an amount then that can only be done via credit card). If you weren't then you will need to contact iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page

  • HT201269 Is there a right, and wrong way to plug the lightning connector into the phone?

    The lightning connector dosen't want to plug into the slot and I don't want to force it, ... is there a right and wrong way to do this bisic and simple step?  Thanks

    No, it is a reversible plug. Either way is fine.
    Just make sure you plug it in straight until it "clicks" into place. It may take a bit of force if new, but check there's nothing in the port first.

  • Huge Acrobat temp files - is this right?

    Hi
    When using the reduce file size function, I have noticed that acrobat produces massive temp files.  I was running some files over night, and acrobat crashed, presumably because it ran out of HD space.  Upon looking for what was using all the space, I found a temp file in "C:\Documents and Settings\{user}\Local Settings\Temp".  This file was 75gig.  On another machine that I was running some files on, the file was 115gig.
    Is this right?  Why does acrobat produce files of such size when the original files are nowhere near that size combined?
    Why doesn't acrobat delete the temp file after it has finished 1 file, then create a new one for the next file?
    Running Acrobat 9 Pro on Windows XP, and Windows 7.
    Edit - I just ran a 3MB file through reduce file size, and acrobat created a temp file of 446MB

    Direct Download Links for Adobe Software
    Mylenium

  • I have bought an iphone 5 from cash converters, I'm waiting for a sim to arrive from my provider. I have left the iphone on the last two days and both days it's turned its self off when I went too look at it. Is this right or could my phone be faulty?

    I have bought an iphone 5 from cash converters. I'm waiting for a sim from my provider to arrive by post. I have left my phone on and twice it has turned its self off, is this right or is my phone seem faulty? I haven't been able to try the phone out yet as I didn't have a small SIM card. I'm worried as to why it would be turned off when I didn't  turn it off.?.

    If it turns off again take it back it,s not your problem ask for a refund or replacement
    BSYDD Uk

  • Dual Networks? Is this right?

    hello, all - i'm sure this topic is out there, i just can't find it, so here goes...
    i have an airport EXTREME base station (n) and TWO airport EXPRESS base stations. according to everything i've heard and read, the network will work only as fast as the slowest connection. which means i won't get N speeds, but only G speeds, as the EXPRESS moves at G only. which also means if i breakdown and buy an apple TV, it won't take advantage of the N speed of my new router.
    HOWEVER, i believe i read or heard that i could, essentially, set up TWO networks - one with the AEBS and the other using the EXPRESS. that way, i'd be serving N speeds to the TV, and G speeds to my computers (G5, mac mini (core duo only) and powerbook - all of which, by the way, can only obtain G speeds). is this true?
    if so, here's what i did - i setup the AEBS (connected to my cable modem) using WDS (at n speed, b/g compatible) as a WDS main, and connected the EXPRESS (as a WDS remote, both on the same channel) to the AEBS via ethernet. it APPEARS i have two networks now under the airport menu in the finder.which, if i've done this right, means i can connect my computers the G network and, when i get the TV, connect that ot my N network. is this at all right, or even close?
    i've read the manuals and searched the chats, but seem to be lost on this one. ANY help, advice, direction is CERTAINLY appreciated.
    THANKS, oh wonderful mac gurus.

    To add to iMacYou's comments,
    i have an airport EXTREME base station (n) and TWO airport EXPRESS base stations. according to everything i've heard and read, the network will work only as fast as the slowest connection. which means i won't get N speeds, but only G speeds, as the EXPRESS moves at G only.
    It is true that the overall bandwidth of the 802.11n network will take a performance "hit" when non "n" devices are connected to it, but not all the way down to 802.11b/g.
    HOWEVER, i believe i read or heard that i could, essentially, set up TWO networks - one with the AEBS and the other using the EXPRESS. that way, i'd be serving N speeds to the TV, and G speeds to my computers (G5, mac mini (core duo only) and powerbook - all of which, by the way, can only obtain G speeds). is this true?
    Yes. It is called a "dual-band" network and setting it up is described in the Designing AirPort Networks Using the AirPort Utility document, starting on page 48.
    if so, here's what i did - i setup the AEBS (connected to my cable modem) using WDS (at n speed, b/g compatible) as a WDS main, and connected the EXPRESS (as a WDS remote, both on the same channel) to the AEBS via ethernet.
    A WDS is NOT what you would want in this scenario, instead you would want to set up a "dual-band" network as described in the link provided above.

  • Does Firefox has this option (which I may not know) to click on my bookmark, link, etc. where to open a new tab without doing this right-click, it is aggravating?

    Hello, I would like to use Firefox as my default browser, but the reason I still use the old Netscape Navigator is that that clicking on my bookmarks Firefox is not opening new tab. Does Firefox has this option (which I may not know) to click on my bookmark, link, etc. where to open a new tab without doing this right-click, it is aggravating?

    Install the addon
    Open Bookmarks in New Tab 0.1.2010043001.
    https://addons.mozilla.org/en-US/firefox/addon/open-bookmarks-in-new-tab/
    Restart on installation.

  • I've installed iPhoto11 and when opening for the 1st time it says that needs to upgrade my library and it is doing this since yesterday. Is this right??

    I've installed iPhoto11 and when opening for the 1st time it says that needs to upgrade my library and it is doing this task since yesterday. Is this right??

    No. Quit and try again. If that fails again,
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. .
    Regards
    TD

  • All Ipad 4 wifi   cellular are unlocked, right or wrong?

    All Ipad 4 wifi   cellular are unlocked, right or wrong?

    Right. Look at the specifications. http://www.apple.com/ipad/specs/

Maybe you are looking for

  • Process controlled Workflow is not starting

    Hi, I have problems with implementing an own process-controlled workflow. The "Sample BC Set for Process Level Definition" /SAPSRM/C_SC_600_001_SP04 is working fine. However I do not succeed in triggering a customer Process Schema for BUS2121. The (f

  • Stop GB from opening most recent song

    Hello, I teach electronic music in a lab (dual G5s with OSX 10.4.10) using Logic and GarageBand, and GB has been annoying me and my students because it always opens the most recent song when started up. I realize that if you close the song before qui

  • Printer Dialog Box in CS4 - Printing Grayscale Images

    I hope I'm not duplicating a new topic. I thought I opened this topic yesterday but I don't seem to be able to locate it in this forum. So, I'll try again. This is a pivotal CS4 question re printer set-up for grayscale images with and without b&w pro

  • Ihome use in europe?

    I am trying to use my ihome in europe and i'm pretty sure i need to use a power converter and NOT just a plug adaptor. The ih5 comes with a class 2 power supply with the following specifications: input 120vac 60 hz 24w output 15vdc 1100ma. how can i

  • Firefox won't let me update. It tells me I have to reboot each time to finish a earlier update. I tried three times.

    When I try to update a popup screen tells me that I need to reboot to complete a previous update. I have rebooted three times and keep getting the same message.