Why can you not insert Objects in List in natural order?

This is a more theoretically question:
I need a dynamic structure to sample informations in a natural order ( by implementing the Comparable-Interface). Set and Map offers natural order but I can't use them (Set-elements are unique and I don't want to implement a <key><value> relationsship for Map).
Are there others solutions than to add the elements in a List in natural order hand made?
Thanks !

Here's a Collection implementation that ensures all elements are allways ordered.
It can be improved for speed, and maybe functionality, but the important thing is that it doesn't break the Collection interface and it's simple.
Have a look and maybe base your implementation on this one.
import java.util.*;
public class SortedCollection
    extends AbstractCollection
    implements Collection {
    private List elements;
    private Comparator comparator;
    public SortedCollection() {
        this.elements = new ArrayList();
    public SortedCollection(Comparator comparator) {
        this();
        this.comparator = comparator;
    public Iterator iterator() {
        return this.elements.iterator();
    public int size() {
        return this.elements.size();
    private void resort() {
        if (this.comparator == null) {
            Collections.sort(this.elements);
        } else {
            Collections.sort(this.elements, this.comparator);
    public boolean add(Object object) {
        boolean answer = this.elements.add(object);
        this.resort();
        return answer;
    public boolean addAll(Collection collection) {
        boolean answer = this.elements.addAll(collection);
        this.resort();
        return answer;
}

Similar Messages

  • Why can I NOT name a Reminder List the exact same thing as a Calendar?

    Remember the good old days when ToDo Lists where automatically related to a specific calendar?  I want that back.  Why can I not name a Reminder List and a Calendar with identical titles?  Why do I have to create a calendar named "Blue Project" and then create a Reminder List and name it "Blue Project 2" or some other iteration?  This is totally asinine.

    "You can look at the Classic Theme Restorer extension to restore some functionality that was lost with the arrival of the Australis style in Firefox 29."
    Precisely. How is "loss of functionality" progress or an upgrade? Why should I have to install an extension just to get a "reload" button? What a pile of crap. Why not have a "Use shit interface" tickbox in the Options dialogue so people can choose if they want their version of Firefox to have pants functionality?

  • Why can I not insert a disc beyond halfway?

    Why can I not insert a disc beyond halfway?

    Direct you to the proper forum for MacBook :
    MacBook Series Forums
    https://discussions.apple.com/community/notebooks?view=discussions
    Mac OS X Forums
    https://discussions.apple.com/community/mac_os?view=discussions
    http://www.apple.com/support/macbookpro
    Mac OS X Help
    http://www.apple.com/support/macbasics/
    Isolating Issues in Mac OS
    http://support.apple.com/kb/TS1388
    https://www.apple.com/support/osx/
    https://www.apple.com/support/quickassist/
    http://www.apple.com/support/mac101/help/
    http://www.apple.com/support/mac101/tour/
    Accounts control panel: login items
    When you shutdown or restart "Reopen Files from last time"
    Apple seems more interested in only showing Mountain Lion features and not Lion, so with that in mind...
    http://www.apple.com/osx/whats-new/

  • HT1933 Why can you not resolve an app purchase  problem simply ! As you have done in the past

    Why can you not resolve an app purchase  problem simply ! As you have done in the past

    Most of the people on these forums, including myself, are fellow users - you're not talking to iTunes Support here.
    If you have a problem with an app that the developer can't/won't help you with then you will need to contact iTunes Support, either as described on the page that you posted from, or via the 'report a problem' link from your purchase history : log into your account on your computer's iTunes via the Store > View Account menu option and you should then see a Purchase History section with a 'see all' link to the right of it ; click on that and you should see a list of your purchases ; find that app and use the 'Report a Problem' link and fill in details about the problem

  • Why can i not insert a disc in my imac

    why can i not insert a disc in my imac

    Any chance there is a disc already in the drive?  Force eject advice:
    https://discussions.apple.com/message/20891926#20891926

  • HT204032 Why can you not use powernap with a custom order iMac with solid state?

    Why can you not use powernap with a custom order iMac with solid state?
    Find it quite ridiculous that a 3 year old mba supports it and not a new iMac

    Agreed.  Why wouldn't you want your Photostream updated while your iMac is sleeping?  I am bummed about this.

  • Using iTunes why can you not backup and save your voicemail?  Guide me through this step by step if possible.  If alternate method MUST be used then provide same.  Truly appreciate this.

    Using iTunes why can you not backup and save your voicemail?  Guide me through this step by step if possible.  If alternate method MUST be used then provide same.  Truly appreciate this.

    Create and delete iPhone, iPad, and iPod touch backups in iTunes - Apple Support  - link doesn't state that voicemail is part of the backup
    iCloud: iCloud storage and backup overview  states that VVM is part of the icloud backup.
    You can also contact your cell phone provider - as voicemail is a carrier feature.

  • Why can you NOT get a straight forward answer on upgrading to Edge?

    On Saturday morning I called customer care with a SIMPLE question about how the Edge Program works. The lady I spoke with gave me information that didn't make sense and told me one of my lines could move to edge and the other could only after 6 months of on-time payments. That didn't make sense to me, how could one be eligible and not the other when the explanation of WHEN would be eligible is contingent upon 6 months payments. I was so irritated I started shopping at other carriers to see what their "Edge" like programs work like and was considering switching carriers. So, I called back and spoke with another guy to find out what my ETF's were and he informed me that I COULD upgrade both lines to a Note 4 for about $5 above what my bill is a mo. each with all of the discounts applied. I told him that I would go to a Verizon store and probably upgrade instead of cancelling. So, I went to the store and was treated TERRIBLY!! I was told that I could not move both of my lines to the edge program with the Note 4. I was told I could move to Edge with both lines but one would have to be a Droid and the other could be whatever phone I wanted. I was blown away with yet another piece of information that was not matching up with what I was told. He said I could call customer care and see if they could do anything. I was BLOWN away that a corporate Verizon store would just turn me away (which was extremely demeaning and embarrassing in front of their other customers) to call customer care again and tell me my best option would be to cancel if I wanted a new phone for the line I wanted to upgrade. So, I called customer care again and spoke with another lady who correctly informed me (I think) of how it works and stated there was nothing she could do on the line that was not eligible which should have been told in the previous conversation with the guy I spoke with. One thing struck me as odd, she said the phone is on a lease with Edge so the phone is never yours, which is something NO ONE mentioned at any point in any prior conversation. So, is that true? I now know where I stand with upgrading but my original questions about how Edge works are still not fully answered and what the last rep stated brings up other questions. If it's "leased" what happens if it's broken or lost? Anyway, I was looking for what I thought was a straight forward answer to a question about how Edge works, how much it costs, and are my lines eligible, etc. and wasted a good hour on the phone and another two driving to a store just to get turned away like as though no one even cared! The last lady I spoke with seemed to care but I'm blown away with the TERRIBLE customer service and COMPLETE lack of ownership. Why can no one take the feedback and DO SOMETHING ABOUT IT and then answer my questions about the Edge program. Bottom line, I'm not looking for a freebie upgrade (though maybe I should for all of the time wasted due to incorrect/inaccurate information). but I'm blown away that no one wants to do anything.
    That all being said, can someone on here explain how Edge works with the discounts and is the phone really a "leased" phone? Pretty sad that I'm resorting to forums to ask other customers how it works but would appreciate any info anyone can share. I'm probably going to port both of my numbers to AT&T if it is true they are a lease and due to all of the terrible customer service.

    I just saw in another post that if it's an "early" edge I would have to turn in the phones. No one told me that either and now I wonder if just forget Edge and port out. What's the advantage of doing Edge with all this confusion and red tape? Is an early edge considered early if you're upgrading with Edge prior to the contract end on the current phone? Verizon Customer Care and Stores REALLY NEED to be up front about this stuff! From what I see here and what others are going through Edge is a TERRIBLE TERRIBLE program.

  • Why can I not insert a signature in Adobe Reader XI

    I can no longer insert my signature or text in Adobe Reader. I am using XI. The Sign option does not appear on the toolbar and is not available to add when I right click on the toolbar. Help! I use this feature often.

    Hi cloeolveigh,
    You need to have Reader extended form and then you will be able to do it:: http://help.adobe.com/en_US/acrobat/X/standard/using/WS58a04a822e3e50102bd615109794195ff-7 e0d.w.html
    Regards,
    Ajlan Huda.

  • Why can I not find my long list of bookmarks?

    What happened to my long list of book marks that I had, and when I click bookmarks tab it just gives me other exploring things to do and none of them are my fu__ing bookmarks. Please excuse the language. Im very frustrated that when you got something good going and you take it away with no explanation of why you want me to make several clicks when it used to just take one?

    You can check for problems with the places.sqlite database file in the Firefox Profile Folder.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.org/kb/Bookmarks+not+saved#w_fix-the-bookmarks-file
    See also:
    *http://kb.mozillazine.org/Lost_bookmarks

  • Why can you not introduce a 2003 server into a 2008 domain?

    Hello,
    So we are going to be upgrading our domain very shortly from 2003 to 2008 R2. I know that we are not able to have a 2003 server in the 2008 forest, but the question is why? I'm trying to find some information on Google but can't actually find the reason.
    I have some ideas as to why, but I wanted some solid info, if possible.
    Thank you!

    In that case it depends on current functional level. If you're at 2008 or greater then you would not be able to bring in a 2003 DC.
    http://technet.microsoft.com/en-us/library/cc787385(v=ws.10).aspx
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • Why can you not have the same Siri voice used in the US version in the UK and Global search should be available

    I have just recently purchased the new iPhone 4s and it is great.
    I am now using Siri a lot,however I don’t like the fact that in the UK only the man's voice is available.
    I think we should have a choice of a Lady / a man assistant and not just a man who's voice is the same/ very similar to the one used for voice control on the iPhone 4.
    Now that we all know that Siri is useless without an internet connection then why only allow Siri to search for items, businesses, addresses etc only in the country you’re in i.e. the UK.
    Where if you just go onto the internet or use the built in maps application you can search anything you   self without restriction.
    I think Apple should really consider thinkingabout this in there next software update for the iPhone 4s.
    Thishan

    we're all users on this forum, so we cannot answer any of your questions.  Feedback goes here:  http://www.apple.com/feedback/iphone.html

  • Why can you not upload a pdf file to the cloud?

    Other online storage services allow PDF files to be uploaded; but not iCloud. Why not?

    Winston Churchill wrote:
    You can do it with Air Doc as I've already said, there's an app for the mobile device and an application in the MAS for the MAC.
    As I posted to you already, as far as I can see Air Doc only lets you upload to the iCloud from iOS, not OS X.  I'd would welcome instructions about how to make it upload from OS X if you know how.

  • HT204053 Why can you not change a @me email account inside my Apple ID?

    I have an iphone 4S and access the cloud from a standard lap top and a standard desktop (not apple) and get confused with the other feeds, and I do not want an alias.
    I simply want to use the same Apple ID and I just simply want to delete the @me email account associated with it and start a new one.
    Is this possible? If not, as I beleive the case, why not?

    Open a new account and stop using the old one, you cannot delete the account but you can ignore it.

  • In CC01, why can I not add object types

    Greetings experts.
    We need to add an object type to the list which shows on CC01(2 etc) .  The New Entries button is greyed out.  Can anyone point me to the reason, or what I need to do to make it active?
    thanks

    Hi,
    Define a profile in OS59. In the profile under Object type profile (detail) section, click on new entries & select the object types from the list as per your need & then save as a custom profile.
    Use this profile on the initial screen of CC01 & then go to Object Types, you should find the object types which you need.
    Regards,
    Vivek

Maybe you are looking for

  • Reporting Services - Content Manager shows all reports for all domain users even without permissions

    I have installed reporting services 2008 in:  Site Settings option / Security only 3 users have added: BUILTIN \ Administrators                 System Manager MYDOMAIN \ user1                          System Manager, System User MYDOMAIN \ user2     

  • Illegal Characters Newly found in RH8 Project

    Hello, I need some help. I opened my RH7 project in RH8 for the first time, and received error messages complaining of file names having illegal characters and I am unable to import ANYTHING (Master pages, images, HTML files, etc.) because the items

  • Conditional csv file upload

    I would like to upload a csv file conditionally - so only if it is a file with the extension .csv. How can I put the regular expression validation into HTMLDB or, more exactly, in the File Browse text field?? Thank you for any assistance! Tom

  • ICloud Photo uploading

    Hi, I am having problems uploading photos from iPhotos on my MacBook Pro to iCloud Photos on iCloud Drive. Its is telling that the file format is incorrect. Having a look into the detail, it tell me that the format is .jpg and it only can upload .jpe

  • My printer isn't in stalling, when I hook it up yo my Dell ..

    My  microsoft teredo tunneling adapter driver, is not working when I hook up my printer?? Can any one help me ??