Is is possible to iterate a LinkedHashMap backwards?

How may i iterate a LinkedHashMap in reverse?
thx

user4199244 wrote:
Is there any specific reason why one can't do this? I mean, it does make sense to be able to do so?!It's quite possible that the linked list in the LinkedHashMap is a single-linked list, in which case iteration in reverse order isn't possible (except with the caveat added before).
I don't know for sure, however.
Another reason would be that they didn't want to complicate the interface too much by adding LinkedHashMap-specific methods.

Similar Messages

  • Possible to iterate attributes?

    Is it possible to iterate through the attributes of an object? Or is there a
    better
    solution for what I want to do?
    I have a form for displaying a simple object, and am doing a
    query-by-example
    type search from this. Unfortunately it's easy to get the form full of 'N/A'
    strings
    and irritating to clear them, so I'd like to suppress them for the search.
    I'd like
    to do something like this:
    for each attribute do
    if attribute is a string or textdata then
    if attribute value = 'N/A' then
    set attribute value = ''
    Any ideas?
    Thanks
    Chris
    Chris Moseley at De Data Ltd
    [email protected]
    http://www.dedata.com.au
    All private email to moz1@ihug please
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    IBC
    -----Original Message-----
    From: Augusto Jun Devegili [SMTP:[email protected]]
    Sent: Monday, July 05, 1999 4:19 AM
    To: John Pianezze; Chris Moseley
    Cc: [email protected]
    Subject: RE: possible to iterate attributes?
    At FORUM'99 there was a company which was selling a Reflection framework
    (for discovering meta information on classes). Unfortunately I can't recall
    its name... :-(
    This is going to be solved with SynerJ, though ;-)
    -----Original Message-----
    From: John Pianezze [mailto:[email protected]]
    Sent: Segunda-feira, 5 de Julho de 1999 05:59
    To: Chris Moseley
    Cc: [email protected]
    Subject: RE: possible to iterate attributes?
    We all wish !!! Smalltalkers can only laugh.
    The class is the only unit in forte that supports any kind of
    meta-information. In this case, it's minimal: you can get its class type,
    and class type supports one method: AllocInstance().
    sigh
    What people tend to do to get around it is to build classes that represent
    methods.
    So for example you might have a class called ApplicationService, which
    contains an array of ServiceMethod objects, and each method describes some
    kind of operation.
    You might define a constant in each method class to describe what it does,
    like ServiceMethod.TRANSACTION_NAME, where TRANSACTION_NAME is some constant
    string.
    Then the only way to figure out how to 'call' the method is by brute force:
    so you'l have a big-ass
    if-then-elseif-then- elseif-then- elseif-then- elseif-then- elseif-then-
    elseif-then-
    block of code.
    sigh
    Alas, this is even how Forte's WebEnterprise maps HTML 'functions' to forte
    functionality.
    It's messy, but it's worth the effort !!
    John Pianezze.
    Security First Technologies
    -----Original Message-----
    From: Chris Moseley [SMTP:[email protected]]
    Sent: Monday, July 05, 1999 4:18 PM
    To: [email protected]
    Subject: possible to iterate attributes?
    Is it possible to iterate through the attributes of an object? Or is
    there a
    better
    solution for what I want to do?
    I have a form for displaying a simple object, and am doing a
    query-by-example
    type search from this. Unfortunately it's easy to get the form full
    of 'N/A'
    strings
    and irritating to clear them, so I'd like to suppress them for the
    search.
    I'd like
    to do something like this:
    for each attribute do
    if attribute is a string or textdata then
    if attribute value = 'N/A' then
    set attribute value = ''
    Any ideas?
    Thanks
    Chris
    Chris Moseley at De Data Ltd
    [email protected]
    http://www.dedata.com.au
    All private email to moz1@ihug please
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • How to Iterate over LinkedHashMap ???

    Hi All
    Can anyone please tell me why am I getting just the last record three times instead of all the shareUserList ??? I think somehow I'm not Iterating it right. can anyone help please.
    Thanks
    public void showMyDiary() {
              Data data = new Data();
              LinkedHashMap<String, String> shareUserList = data
                        .execFunction("{ ? = call pa_dump_xml.fn_user_diary_share_list("
                                  + registrationController.getLogin().getUserId() + ")}");
              // dataList of the richfaces web control
              shareList = new ArrayList<ShareDiaryDetails>();
              Iterator it = shareUserList.entrySet().iterator();
              while (it.hasNext()) {
                   Map.Entry<String, String> pairs = (Map.Entry) it.next();
                   System.out.println(pairs.getKey() + " = " + pairs.getValue());
                   ShareDiaryDetails shareDetails = new ShareDiaryDetails();
                   for (Map.Entry<String, String> e : shareUserList.entrySet()) {
                        if (e.getKey() == "PDSH_ID") {
                             shareDetails.setShareDiaryId(Integer.parseInt(e.getValue()));
                        } else if (e.getKey() == "DIARY_MUSR_ID") {
                             shareDetails.setDiaryUserId(Integer.parseInt(e.getValue()));
                        } else if (e.getKey() == "SHARE_MUSR_ID") {
                             shareDetails.setShareUserId(Integer.parseInt(e.getValue()));
                   shareList.add(shareDetails);
         }Edited by: EJP on 17/07/2011 09:45: added {no format}{no format} tags. Please use them.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    1) When posting code, use code tags so it will be readable: http://forums.oracle.com/forums/ann.jspa?annID=1429
    2) When you want to compare objects' states, which includes comparing Strings' contents, use equals(), not ==. This may or may not be related to the specific problem you're asking about, but it's definitely wrong that you're currently using ==.
    3) It's not clear what your actual problem is, but after you fix #2, if you're still having a problem, post again, using code tags as described in #1, and explain your problem as clearly as possible.

  • Iterating over LinkedHashMap (doubly-linked) backwards

    I have a complete lack of understanding here. I interpret "doubly-linked" to mean every node has a pointer to the next node plus a pointer to the previous node. I don't see a way to get an Iterator that goes from the tail to the head of a LinkedHashMap, however.
    How do I iterate backwards over a LinkedHashMap?
    If I have to use some external object to reverse the order of the keys, what is the point of doubly-linking the list?
    Thanks for any help.

    pbyhistorian wrote:
    I have a complete lack of understanding here. I interpret "doubly-linked" to mean every node has a pointer to the next node plus a pointer to the previous node. Yes, but that's an implementation detail that you as a user don't need to know about to use the features of the data structure. (It does come into play where performance is concerned.)
    I don't see a way to get an Iterator that goes from the tail to the head of a LinkedHashMap, however.If it's not in the docs, then it doesn't have one.
    Note that it would be possible to iterate backwards even without such an internal implementation detail. And even if such an implementation detail is there, that doesn't mean it will be exposed in the public interface.
    How do I iterate backwards over a LinkedHashMap?If there's no method provided, you don't.
    If I have to use some external object to reverse the order of the keys, what is the point of doubly-linking the list?It may still be useful for the implementations of some of the methods, even if it's not directly exposed to the user.

  • Iterate DB using DBcursor- get with DB_DBT_USERMEM flag set for DBT

    Have BDB running in TDS mode. Want to iterate over a complete database using a DBcursor from start to end. Set the DB_DBT_USERMEM flag on the DBT structure with data pointing to a fixed sized user allocated memory block to hold the contents of a single record read. Currently cursor-get fails with DB_BUFFER_SMALL. I assume that this is because cursor->get retrieves more than one record.
    Is it possible to iterate over the DB using the said cursor while allocating user-memory for only one (1) database record? Each call to cursor->get with DB_NEXT / DB_PREV / DB_FIRST /DB_LAST etc would update the single record entry.

    Hi Kedar,
    No, DBcursor->get() retrieves multiple key/data items if you're using the DB_MULTIPLE or DB_MULTIPLE_KEY flags. See "Bulk Retrieval":
    [http://www.oracle.com/technology/documentation/berkeley-db/db/programmer_reference/am_misc_bulk.html#am_misc_bulk_get]
    You only want to retrieve a single record per call, hence are not using the aforementioned flags. In this case the DB_BUFFER_SMALL error indicates that the length of the requested/retrieved item is larger than that specified for the DBT via its "ulen" field.
    [http://www.oracle.com/technology/documentation/berkeley-db/db/api_reference/C/dbt.html#dbt_DB_DBT_USERMEM]
    If you want to iterate over all the records in the database (including duplicates, if the database is configured to support them) you should use the DB_NEXT flag.
    Note than when the DB_BUFFER_SMALL error is returned the "size" field of the DBT is set to the the length needed for the requested item; you can inspect that value to decide how to size your supplied buffer (or you may know in advance the size of the data items in the database).
    Here is an excerpt from the example code in "Retrieving records with a cursor" with the necessary adjustments for the data DBT:
    [http://www.oracle.com/technology/documentation/berkeley-db/db/programmer_reference/am_cursor.html#am_curget]
         DB *dbp;
         DBC *dbcp;
         DBT key, data;
         int close_db, close_dbc, ret;
         /* Acquire a cursor for the database. */
         if ((ret = dbp->cursor(dbp, NULL, &dbcp, 0)) != 0) {
              dbp->err(dbp, ret, "DB->cursor");
              goto err;
         close_dbc = 1;
         /* Initialize the key/data return pair. */
         memset(&key, 0, sizeof(key));
         memset(&data, 0, sizeof(data));
         /* Retrieve data item in user suplied buffer. */
    #define BUFFER_LENGTH 1024
         if ((data.data = malloc(BUFFER_LENGTH)) == NULL)
              return (errno);
         data.ulen = BUFFER_LENGTH;
         data.flags = DB_DBT_USERMEM;
         /* You can supply your own buffer for the key as well. */
         /* Iterate through the database. */
         while ((ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT)) == 0)
              /* Operate on the retrieved items. */
         if (ret != DB_NOTFOUND) {
              dbp->err(dbp, ret, "DBcursor->get");
              goto err;
    err:
         // ...Regards,
    Andrei

  • Is it possible to compare all files in a directory?

    Hi
    Is it possible to iterate through all the files in a directory and compare them? i know how to compare two files, but i need to compare about 576.
    cheers for any advice
    ness

    Well, its gonna be an expensive comparison since there is no non-arbitrary way to iterate through the files, but try:
    String f1, f2;  // the comparing files
    //get a primary list of files to iterate through
    Process p = Runtime.getRuntime.exec("ls");  // if in Linux
    BufferedReader pri =
        new BufferedReader(
        new InputStreamReader(
        p.getInputStream()));
    while((f1 = pri.readLine()) != null){    // for each file...
        Process q = Runtime.getRuntime.exec("ls");  // get all file names
        BufferedReader sec =
            new BufferedReader(
            new InputStreamReader(
            q.getInputStream()));
        while((f2 = sec.readLine()) != null){   // and for each of these
            if(!f1.equals(f2))  // as long as it's not the same file
                DO_COMPARISON(new File(f1), new File(f2));   // compare them
    }

  • Iterate through HashMap ?

    Hello,
    is it possible to iterate through a Java HashMap somehow?
    Or is there any other iterable data structure i could use (I need to get objects from the data structure by using an integer value as key ) ?
    thanks!

    It depends...
    Simple answer: you can use keySet() or values() to get respectively a Set or a Collection, then you iterate on them (using iterator()).
    But you have no guarantee on the order of iteration.
    Now, a data structure using an integer as key is commonly called... an array! Half joking, it works well if these integers are consecutive or of limited range.
    If you need to iterate in increasing key values, use a TreeMap.

  • Printing doubles/floats

    hi,
    i'm trying to convert a double (or float, either one) to a string and print it to the screen. i can't find a way to do it that maintains ALL of the digits in the number - at best, 15 or so digits after the dec point are kept and the rest cut off. i don't know the number's precision in advance - i just want to be able to capture the accurate number in a string, regardless of the precision.
    thanks,
    --vlb1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Then you can set DecimalFormat for the maximum possible range of digits after a decimal point and then once you have a String iterate through it backwards until you reach a non zero digit that will be you precise decimal precision.
    This whole solution is backwards - but today is Friday and my brain is a lot like Jello right now :)

  • Multiple disappointments with new Mac Mini

    I 'upgraded' my trusty old eMac to an Intel Mac Mini running Leopard but so far I have been very disappointed.
    So far;
    DSL USB modem not recognised - had to be replaced.
    Umax scanner not supported - will have to be replaced
    All my pre-OSX software cannot be run.
    iMovie7 not backwardly compatible with my iMovies - iMovie6 is the last one that will be produced that will access my video.
    My Panasonic NV-EX3 video camera is not recognised, so I can't use iMovie6 anyway.
    When logging out of accounts I get a spinning clock for more than a minute.
    After sleep the mouse is usually frozen, sometime requiring a reboot to get it going again.
    I have trawled through these discussions and found numerous people complaining about the same or very similar issues, but very few suggestions for solutions or workarounds, and the few that I have tried have done nothing for me. For example, repairing disk permissions, and unplugging power and other connections for >20 secs.
    I am getting very frustrated with this - hundreds of pounds spent to end up with loads of problems, further expense and tons of stress.

    Sorry to jump in at this point, but did you transfer your applications from the eMac using the migration assistant? If so, that would certainly cause the poor performance since you migrated PPC-only software to your Intel machine, meaning it'll run very poorly.
    If you installed your software from disks and downloads, and used any 'non-native' versions of software, then this too will slow your system. You can check for that by opening Activity Monitor and looking for processes marked as belonging to 'Rosetta' - which is the translator included in Intel versions of MacOS to allow it to run earlier (in other words non-Intel-native) software.
    Either of the above will create situations where you see the spinning beachball a lot, particularly if you're trying to do a number of things at once. Thus, what software do you have installed, where did it come from, and what are you running at any given time on the system?
    It is true though that some older software (the pre OS X stuff) and legacy peripherals won't be usable, simply because it is not possible to make systems fully backwards compatible without giving up significant potential performance gains or at considerable cost. A Umax scanner that is SCSI based for example will be totally incompatible with virtually any Mac built in the last 5+ years (as I well know because I have one that I have had to throw away) but at the same time, technology has moved on in that time sufficiently that the older devices are often not much worth using anyway.
    I'm not clear in what way the Panasonic camcorder doesn't work however, since I can't find much information on the subject. Typically up until iMovie 7, camcorders needed to be based on miniDV tape and have firewire connectivity. If this unit has that, it should work. iMovie 7 has far wider camcorder compatibility, and if this camcorder works with that version of the software, there is nothing to prevent you using iMovie 7 in future projects. If not, then which software were you previously using with it?
    The stress and frustration is understandable, but if these problems still persist, and we can break down the process you went through to do the install and set up, and the issues that remain, much should be fixable. At the heart, the mini you have os actually very powerful and fast, even if it doesn't seem so.

  • Transferring Messages and associating with Contact...

    My old phone is a Nokia N70 and I've had my new N95 for about 2 weeks now.
    I'm trying to transfer the text and multimedia messages from my old phone to my new one, but I am having limited success. If I backup the old phone's messages using PC Suite and then restore them to the new one, the messages are transferred BUT the "From" line appears as the mobile number that sent the message, not the name from the address book.
    I have already transferred the contacts correctly (using the utility supplied with the phone) so the relevant address book entries are there.
    Is there any way to force the phone to associate the numbers with names in a messaging folder or is it just happening, as far as I can tell, when a message is received? If I receive a text from an unknown number and then "Save to Contacts" it still doesn't update the "From" line to show that new Contact name.
    I'm sure my old 6230 used to have this functionality - if it's not possible it seems like a backward step (similar to the lack of a 'year' for an anniversary on the calendar so the phone just knows the date of one, not how old someone is or how long they've been married, etc!).
    Many thanks for any help anyone can provide!

    Braden, after inporting your contacts and opportunities use the "Opportunity Contact Role" import to make the association by using the opportunity external unique ID and the contact external unique ID.

  • USB Install

    OK, so I installed Arch onto my 4gb USB Stick, as per usual procedures (I also read through the "Installing Arch Linux on a USB Key" wiki article.
    The problem is that everything worked fine, then I did some updates, which seem to have broken the installation. I suspected a kernel upgrade had done it, so I followed through the guide to run mkinitcpio with the USB hook (I forgot to do it on first install, I fixed this and it worked OK) but now I'm back to not being able to boot, with mkinitcpio not fixing anything.
    I have an Arch CD that I can boot from, so, any ideas?
    Thanks so much in advance!

    scottuss wrote:
    JuseBox wrote:
    scottuss wrote:
    OK, so I installed Arch onto my 4gb USB Stick, as per usual procedures (I also read through the "Installing Arch Linux on a USB Key" wiki article.
    The problem is that everything worked fine, then I did some updates, which seem to have broken the installation. I suspected a kernel upgrade had done it, so I followed through the guide to run mkinitcpio with the USB hook (I forgot to do it on first install, I fixed this and it worked OK) but now I'm back to not being able to boot, with mkinitcpio not fixing anything.
    I have an Arch CD that I can boot from, so, any ideas?
    Thanks so much in advance!
    Have you tried to roll back the "updates" you installed?
    No, but I'd like to run with the versions of packages I have installed now if possible. I suppose going backwards is worth a try, but I will want to update at some point!
    Thanks for your reply!
    The thing is if you can get it to work by rolling back then you know there is an issue with a package... Then i would install packages one by one until you find the package that broke your install.  Then you can report a bug report or try to find a fix narrowing it to one package

  • Search in ADF does not work

    Hello.
    I have created a search form with two iterators one for the results and the other for the search criteria. The search form works as expected. The name of the view that i am using is "MasterPartyView1". When i execute the following code
    ViewObject voMasterParty = appMod.findViewObject("MasterPartyView1");
    voMasterParty.setWhereClause("Id = " + MasterPartyId);
    voMasterParty.executeQuery();
    Row rowDest = voMasterParty.first();
    in a backing bean and i go to the search form the only result that i a have is the row that i found in this statement (voMasterParty.setWhereClause("Id = " + MasterPartyId);).
    Why is that?The adf search does not go every time in the database to fetch rows?
    the only workaround for the moment is that i put these two extra lines in the backing bean
    voMasterParty.setWhereClause(null);
    voMasterParty.executeQuery();
    which is not correct because i am fetching all the rows from the database i think.
    Thank you in advance
    Periklis

    Frank thanks a lot for your answer but i still have some questions.
    1 question: One workaround that i found is to the search with the view named MasterPartyView1 and have another instance of the view object(MasterPartyView2) in order to perform the custom search(setwhereclause).This seems to work. Is this approach correct?
    2 question: if i understood correctly you say that both iterators point to the result set of the query (one row) and such is not possible to find other rows. But in the search form there is an invoke action
    <invokeAction id="AlwaysInFindMode" Binds="Find"
    RefreshCondition="${bindings.MasterPartyView1SearchIterator.findMode == false}"/>
    that to my understanding puts the iterator in Find mode, thus making the input text fields available for criteria again. So the search iterator now points to QBE and it is possible to iterate over a collection of QBE criteria rows. is this correct?And if it is why it does not work as expected?Why it does not bring other results?Why the iterators (the seach iterator and the results iterator) still point to the newly created result set?
    Thanks in advance
    Periklis

  • Adressing multiple copies of Movieclips with the same instance name

    Is it possible to iterate through MV copies with the same instance name? It would be very useful for my project.

    you can copy movieclips with the same instance name but you'll only be able to easily control (with actionscript) the last created instance.  the rest will be difficult to reference.
    although, if the only movieclips attached to the parent are the ones you are interested in and you want to do that same thing to all of them (say rotate them all), you can do that without giving them distinct names.

  • How to use cursor function for nested xml

    Hi,
    i have a query for XMLQuery like
    select * from bills where bill_id=????
    it results in something like
    <bills>
    <bill>
    <city>london</city>
    <amount>44</amount>
    </bill>
    <bill>
    <city>london</city>
    <amount>988</amount>
    </bill>
    <bill>
    <city>new york</city> <amount>59</amount> </bill>
    </bills>
    but i want xml output to be sorted for city names adding one more level location like
    <bills>
    <location city="london">
    <bill>
    <amount>44</amount>
    </bill>
    <bill>
    <amount>988</amount> </bill>
    </location>
    <location city="new york">
    <bill>
    <amount>59</amount> </bill>
    </location>
    </bills>
    it should be possible to iterate through the same table to gather informaton with the help of cursor function, but never used CURSOR before.
    any idea?

    sreese wrote:
    p_desig works as a comma delimited string without the NVL function, that's not the issue.
    It IS the issue .. you need to provide  a SAMPLE so we can see what you're doing ..
    How are you "passing it in" ?
    option A:
    procedure ( in_var  in  VARCHAR2 )
    AS
    and nvl(sn.c_attribute1,'x@#$%') in nvl(in_var,'x@#$%')
    option B:
    and nvl(sn.c_attribute1,'x@#$%') in nvl(&1,'x@#$%')
    .. or some other method?

  • Button not working when using JumpTo Captivate 8

    I seem to be having a problem when using smart objects as buttons, I select use as button, select jumpto and select the slide , in this case home, I have named the home slide home, but when previewing the button doesn't work, this is pretty basic and I'm just about to start a large project , am I missing something or doing something wrong? Would appreciate some help please. 
    Many thanks
    Sue

    Hi there
    Do you by chance have question slides? If so, it's possible that you are disallowing backward movement.
    Quiz > Quiz Preferences > Settings.
    Cheers... Rick

Maybe you are looking for

  • Sequencing and Trigger on Oracle 9i lite database

    We created a schema (TESTSCHEMA) on Oracle 8.1.7 Enterprise edition and have a created a trigger which will use the sequence object to generate primary key for the table (TEST_TABLE) Sequence creation: CREATE SEQUENCE TESTSCHEMA.TEST_TABLE_SEQUENCE S

  • Newbie on BI 7

    Dear gurus, I am new to BW 7 and intend to load data into the system using a flat file using DTPs and transformations. I created 3 characteristics: z001, z002, z003;  z002, z003 are attributes of z001. I create my cube and data source also. I created

  • Weekly Kernel Panic on brand new MacbookPro. Help!

    I bought a new Macbook Pro a month ago. Every single week I get a Kernel Panic. Once I was surfing the Internet, another time I was writing a document with Word, and the last I was using Logic Pro. I have no idea what can be causing it but I read tha

  • Metalink Doc ID 359145.1 (TIMESTAMP and TSTZ & TSLTZ)

    Hello All, I read Metalink Doc. ID 359145.1 (Daylight Savings changes on the Oracle databases) which talks about 2 types of patches, which are as follows. Oracle JVM Patch If Oracle JVM is not installed in the database, there is no need to apply this

  • IPhoto crashes constently after iCloud move

    I've upgraded to iLife 11 & just done the move to iCloud - now iPhoto crashes constently. Any ideas on how to fix this??