IComparable (CompareTo takes one argument) and IComparer ( Compare takes two arguments)

I was looking at the MSDN article
https://support.microsoft.com/en-us/kb/320727 on IComparable and IComparer. IComparable provides default sort order and IComparer provides custom sort order.
ICompareable interface requires that CompareTo method and takes one argument
IComparer interface requires that Compare method be implemented and takes two arguments
My question is : I can understand comparing two arguments, because we are comparing two objects / strings / int whatever the case be. But I don't understand IComparable Compare method which takes one argument, what is being compared with what? Below is the
code from the article.
int IComparable.CompareTo(object obj)
car c = (car)obj;
return String.Compare(this.make, c.make);
The this instance of the class is compared with the object obj based on the make. I guess I don't understand where are the two entries picked up from and in what order. Because this means the current instantiated class holding the current entry, then
what is the object? This is probably implementation detail on how the Sort works on the array. But I for some reason feel that the method with two arguments is intuitive as in IComparable Compare method

When there is a comparison job, it can be performed in two ways. You ask the object itself (i.e. the comparable) for the result. It then compares itself with the compared object and gives the result. Another way is to employ a judge. You give him the two
objects being compared together and ask him for the result.
When implementing IComparable<T> in a class, you want the class itself give you the result. The advantage of this approach is that, you don't need another object to compare the result as a judge. Comparison is done implicitly. However, the limitation
of this approach is that, you can implement the interface only once in a class.
The second approach has more flexibility, because you can change the judge and employ any judge as you want to give you the proper result. However, you need to create an instance of the IComparer<T> and use it explicitly to perform the comparison.

Similar Messages

  • Magic Mouse  question. I have set this in Preferences by ticking Swipe between pages with  one finger and also Swipe between full-screen apps with two fingers,  however when I try to do the latter, the 2 finger swipe will take me only to the dashboard and

    It's a Magic Mouse question. I have set this up in Preferences by ticking Swipe between pages with one finger and also Swipe between full-screen apps with two fingers,  however when I try to do the latter, the 2 finger swipe will take me from the app that I am on to the dashboard only and not to my other open apps.
    I also find that Smart zoom only works with some apps, for instance not with Word docs or email.
    How can I correct this please?

    Just figured out it also does not work with the Mail app.

  • I have an extensive aperture library on my computer's hard drive and I want to break it up into separate smaller libraries on external hard drives.  How do I take projects from one library and add them to another one?

    I have an extensive aperture library on my computer's hard drive and I want to break it up into separate smaller libraries on external hard drives.  How do I take projects from one library and add them to another one?

    Coastal,
    Frank gave you the exact answer to your question. 
    However, I would like to ask if you are indeed asking the right question.  Do you really want different libraries?  The implications are that you have to "switch" libraries to see what's in the others, and so that your searches don't work across all of your pictures?  If so, then you asked the right question.  If not, you may be more interested in relocating your masters to multiple hard drives so your library gets smaller, instead of breaking up the library.
    nathan

  • How do you take pictures from one library and put in another library??

    How do you take pictures from one library and put in another library??

    Options:
    1. Export from iPhoto A to the Finder, then import to iPhoto B
    This gets the photo over, but no versions, no edit history and not all the metadata
    2. Use iPhoto Library Manager
    This gets everything: versions, edit history and all the metadata.
    Regards
    TD

  • How you you take an ipod off of one account and transfer it to another account?

    how you you take an ipod off of one account and transfer it to another account?

    If you mean iTunes libraries, sync it with the desired iTunes library. If you mean iTunes Store accounts, an iPod can contain content from five of them at once with no special actions needed.
    (57859)

  • How can you take a photo from one event and put it in another, without dragging to desktop and dragging back into iPhoto and moving it to the event folder I want it in.

    As the title says I need help on how to take a photo from one event and put it in another, without dragging to desktop and dragging back into iPhoto and moving it to the event folder I want it in. Right now when I want to move a picture from one event to another I drag it to my desktop then delete it from iPhoto then I drag it back into iPhoto and put where I want it.An example would be taking a photo from the Christmas event and add it to a specific person event.  Can I do that within the events section without all the dragging. Also is there anyway I can remove duplicates from iPhoto without going through each and every file. Any help would be greatly appreciated.

    Apple doesn't make it easy to do what you want.  However, here's how I do it. 
    Select the photo you want to move and create a new Event for it via the Event ➙ Create Event menu option.
    In the Event mode select the new Event with the one picture and drag it onto the Event you want to move the photo to.

  • Is there anyway to take a downloaded app from one computer and put it on another without rebuying it. I have a macbook that I bought the new iMovie and iPhoto on, but I would rather it be on my iMac. So is there anyway I can change it?

    Is there anyway to take a downloaded app from one computer and put it on another without rebuying it. I have a macbook that I bought the new iMovie and iPhoto on, but I would rather it be on my iMac. So is there anyway I can change it? I thought that if I bought it the apps on my macbook, they would be avaliable on my imac like the mobile devices operate. The macbook has 10.6.8 cause its a older model and I think lion would slow it down. Any help??

    Just redownload it on the other computer by logging into the App Store with the same Apple ID you used to purchase it.

  • I have a few hundred duplicates in my iPhoto library, but the file sizes are different.  So one is 1.3mb and one is 567kb.  I want to delete the smaller ones, but short of comparing each duplicate, is there a way to do this?

    I have a few hundred duplicates in my iPhoto library, but the file sizes are different.  So one is 1.3mb and one is 567kb.  I want to delete the smaller ones, but short of comparing each duplicate, is there a way to do this?  I've been looking at Duplicate Annhilator but I don't think it can do it.
    Thanks!

    I just ran a test with iPhoto Library Manager, Duplicate Annihilator, iPhoto Duplicate Cleaner, Duplifinder and Photodedupo.  I imported a folder of 5 photos into a test library 3 times, allowing iPhoto to import duplicates.  I then ran the 5 photos thru resizer to reduce their jpeg compression but all other aspects of the file the same.
    None of the duplicate removal apps found set that was reduced in the file resizer. That's probably due to the fact that the file creation date was being used as a criteria and the resized photo would have a different file creation date even though the Image Capture date was the same.
    They all found the 3 regular duplicates and some of them would mark two and leave the 3rd unmarked.  iPhoto Duplicate Cleaner can sort the found duplicates by file size but if the file was edited to get the reduced file size it might not be found as it would have a different file creation/modification date. 
    iPhoto Library Manage was able to find all duplicates and mark them as such if the file names were the same the the filename option was selected.  Otherwise it also missed the modified, resized version.  It allowed one to select the one photo to save before going to work on the library.
    So if a photo has been reduced in image quality or pixel size it will not be considered a duplicate.
    OT

  • I accientally synced my iPhone to 2 different computers. Now my older apps are on one computer and new apps are on another.  Every time I try to sync all apps on one computer it takes the other apps of and just syncs what is on that computer - Help please

    I accientally synced my iPhone to 2 different computers. Now my older apps are on one computer and new apps are on another.  Every time I try to sync all apps on one computer it takes the other apps of and just syncs what is on that computer - Help please
    I cannot for the life of me figure this out.

    What you need to do is connect your phone to iTunes but do not click sync.  Go to File at the top and click transfer purchases from phone, that'll put all your apps into iTunes.  When it's done transferring, locate your phone on the sidebar and click it.  Then find the apps option above the picture of your iphone, you can select which apps you want or don't want on your phone.  After selecting your apps then you can sync.  Once you do this you should never have your problem anymore.

  • How can i take photoshop off one computer and put it on another

    How can I take photoshop off one couputer and put it on another?

    Hi Beth, welcome to the discussions!
    Might be a good idea to also post over in the iPhoto forum if you haven't tried this yet as this is a common topic on their boards.
    You may be able to get your iPhoto library back by rebuilding it. I've done it, but's it's been a long time, so don't want to mislead you on anything. The guys over in the iPhoto forum are real experts and should have some fixes for you.

  • Hi, I need to take my daughter off from our Apple account and set up her own. So, delete her from one account and create her own. Realize I sound imbecilic for not knowing how to do this. Any ideas? Thank you so much. Jules

    Hi, I need to take my daughter off from our Apple account and set up her own. So, delete her from one account and create her own. Realize I sound imbecilic for not knowing how to do this. Any ideas? Thank you so much. Jules

    You don't have to take her off your account exactly: she needs to sign out from your account on her computers and devices. Then she can obtain an Apple ID at http://appleid.apple.com and use it to sign into System Preferences or Settings>iCloud.
    However, there are some issue about this. If she has been syncing her calendars and contacts to your account then the data will disappear from her devices, but remain on your account. Individual calendars can be exported  as .ics files and reimported into her account, but if she has her contacts mixed up with yours she will have to enter them individually in the new account (or export yours, import them into hers, and delete the ones she doesn't want.
    More intractable is the email issue. She cannot move an address from your account to hers, so if she has been using a alias on your account to have her own address she cannot transfer it. She will have to create a new email address.

  • What is interface?what is EDI? take one example and explain it?

    what is interface?what is EDI? take one example and explain it?

    Hi,
    Electronic Data Interchange (EDI) is a set of standards for structuring information to be electronically exchanged between and within businesses, organizations, government entities and other groups. The standards describe structures that emulate documents, for example purchase orders to automate purchasing. The term EDI is also used to refer to the implementation and operation of systems and processes for creating, transmitting, and receiving EDI documents.
    Despite being relatively unheralded, in this era of technologies such as XML services, the Internet and the World Wide Web, EDI is still the data format used by the vast majority of electronic commerce transactions in the world.
    EDI testing is to test the EDI transmissions and validate the accuracy and consistency of data mapping between the sender, translator/middleware (if any) and receiver systems.
    http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/EDI_tutorial.html
    Rewards points if is useful.

  • How do I take one picture and combine it with another to make one?

    I'm new at this but I want to take one picture and then another picture and combine them making it look like it all taken at the same time. Any help?

    In Editor, go to the expert tab.
    Open picture B, the one you wish to select something from to add to another picture.
    Use one of the selection tools, e.g. selection brush, lasso tool, to select the object. You will see an outline ("marching ants") once the selection is complete
    Go to Edit menu>copy to copy the selection to the clipboard
    Open picture A, then go to Edit>paste
    Use the move tool to position object from picture B.
    In the layers palette you should see picture A as the background layer, and object B on a separate layer

  • How do you take information from one layer and switch it to another?

    I am trying to figure out how to take pictures and text that I have already placed on one layer and switch it to another layer. I have like 50 pages worth of information and I am trying to look for the easiest way to do this. In illustrator and Photoshop, its pretty easy. Wanting to know if it is the same because I have been trying but it is not there. Just in case it matters, Im using CS5 on a pc. Help is greatly appreciated.

    Hi Martin,
    Please follow the below steps.
    Step 1
    Create the separate layer. Select the content you want to move.
    Step 2
    Go to check layer panel, near the pen symbol icon, the below box drag to move up to the image layer, see sample
    Step 3
    This option use spread wise content, it will complete the task with fast. If more faster, please raise as question to Scripting Forum, they can suggest the tool.

  • Can someone take the eyes of one photo and move it to the other? . we took family photos and his eyes are all squinting except in 1 photo and my wife wants those eyes on the a different picture. please email me at Dunworth.m Gmail and i will send you the

    Can someone take the eyes of one photo and move it to the other? . we took family photos and his eyes are all squinting except in 1 photo and my wife wants those eyes on the a different picture. please email me at Dunworth.m Gmail and i will send you the photos. i can pay pal you like 5 bucks apon completion

    Topic or subject titles should be clear, pertinent and concise so that individual users can tell at a glance if they can help or not.
    That field is not for attempting to fit your entire question in there.
    Please keep this in mind next time you post.  Thank you.

Maybe you are looking for

  • Excise invoice -removal time

    hi, in excise invoice printout we need to print date & time of issue & removal BUt in J1ip There is no option to enter this date & time pl suggetest is there any field where we can enter this date & time of issue & removal so that it gets printed in

  • [SOLVED] XAMPP 1.8.0 + virtual hosts = 403 access forbidden

    Hello, all. I am happy migrant from ubuntu to arch, but have problem, which i can't solve myself. I need to setup xammp for local development. My actions Install last xampp from aur Run lampp Open locahost, there is "xampp welcome page" Open localhos

  • Can I has 2 different version of flash at the same time?

    I am using flash MX 2004, now I planning to install CS3 but I do not want to uninstall MX 2004 because I has some work on it. I afraid that after I change I cannot open my file. Can I has 2 flash at the same time? By the way I had installed flash pla

  • Using Obvious library results in error in Awesome WM

    Hello, I'm trying to configure Awesome to have a battery meter.  Using Obvious seemed like the easiest route.  When I add even this one line to my rc.lua: require("obvious") I get this error when running Awesome: /usr/share/awesome/lib/obvious/lib/ho

  • Problems with Wordpress Slideshow (Was: Getting issue)

    I have created front end of website http://youroutsourcer.com/ now the problem is when you see the slides it is showing a slides and 1 line with each slide, i want to add content on it and it look very unprofessional that having just heading. i can u