Swap method for list of Nodes not working correctly

Ok so I'm basically messing with a list of nodes, swapping, reversing, and cycling. My only problem is the swap method that I am implementing.
It starts out with a boolean to see if the position is valid, and if so, it will go through the instructions.
The first condition is that if the the position to be swapped( which is named secondPosition) equals 2, it goes through a certain method, which I have no problem with...BUT in the second condition, if secondPosition is greater than 2, I have to use a different way of swapping them...Of course, I have to change their references and not positions, since that's the way nodes work. Also, at the end of the list of nodes, the reference will be null, so I have to deal with that as well, which is to set it to the first node in the list. I am very sure I am writing the code for swapping correctly, but yet it seems that the lists that I swap in the second condition don't even change at all! I don't really see how its happening...could anyone help???
Here is the run:
TESTING SWAP
Trying an invalid swap (position 0)
Passed test
Passed test
Trying an invalid swap (position 4/list size 3)
Passed test
Passed test
Trying a valid swap (position 3/list size 3)
Passed test
*** Failed test (bad list on swap)
*// the result is supposed to be: John Jack Jill, but the list stays in its initial state*
Jack
Jill
John
Trying a valid swap (position 3/list size 4)
Passed test
*** Failed test (bad list on swap)
*// result is supposed to be Jill Jack John Jerry, yet the list stays in its initial state*
Jill
John
Jack
Jerry
Trying a valid swap (position 4/list size 4)
Passed test
*** Failed test (bad list on swap)
*//result is supposed to be Jill Jack John Jerry, yet it still stays in its initial state*
Jill
John
Jack
Jerry
Trying a valid swap (position 2/list size 3)
Passed test
Passed test
Here is the method:
     public boolean swap(int secondPosition)
          boolean valid = false;
          if( secondPosition == 2)
               valid = true;
               Node<T> nodeOne = this.firstNode;
               Node<T> nodeTwo = nodeOne.getNextNode();
               Node<T> nodeThree = nodeTwo.getNextNode();
               firstNode = nodeThree;
               nodeThree = nodeOne;
               nodeOne = nodeTwo;
          else if( secondPosition > 2 && secondPosition <= length)  //this loop is where I'm having problems
               valid = true;
               Node<T> nodeBefore = getNodeAt(secondPosition -2);
               Node<T> nodeOne = nodeBefore.getNextNode();
               Node<T> nodeTwo = nodeOne.getNextNode();
               Node<T> nodeAfter = nodeTwo.getNextNode();
               if( nodeAfter == null)
                    nodeAfter = firstNode;
               nodeBefore = nodeTwo;
               nodeTwo = nodeOne;
               nodeOne = nodeAfter;
          return valid;
     }

I'm sure there is a bug in swap method.
if( secondPosition == 2)
               valid = true;
               Node<T> nodeOne = this.firstNode;
               Node<T> nodeTwo = nodeOne.getNextNode();
               Node<T> nodeThree = nodeTwo.getNextNode();
               firstNode = nodeThree;
               nodeThree = nodeOne;
               nodeOne = nodeTwo;
          }All this code does not actually reorder your nodes. All it does is move a bunch of pointers about. For example firstNode will end up pointing to the last node in the list but this does not automagically make it the first node. If you were to make a call to firstNode .getNextNode I'm sure it will return null and not the next node in the list like you think.

Similar Messages

  • HT5100 Can i have back my money for purchased Apps wich not working correctly ???  thnx

    THIS APPLICATION NOT WORKING PROPERLY, LIKE IS WRITTE ON MANUAL AND I JUST WAIST MY MONEY.  CAN I HAVE MY MONEY BACK ???   MANY THNX FOR ANSWER.

    First Contact the Developer of the App.
    If necessary Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • List Binding is Not Working Correctly for an ADF Table

    I created an ADF Select One Choice for a field being displayed in an ADF Table - mutliple records.
    The issue I'm seeing is that all the records in the ADF Table are showing the same value in the field defined as a "List", but the field values are not all the same.
    It almost looks like the List is taking the value in the first record and assigning the value to all the other records in the ADF Table.
    Please help.

    The solution is explained here:
    http://www.oracle.com/technology/products/jdev/tips/muench/screencasts/editabletabledropdown/dropdownlistineditabletable.html?_template=/ocom/technology/content/print

  • Tab Page visible property node not working correctly

    I am making a vi in which we have a tab control with 6 pages and to move from one page to another there is ring control with option for every page on page 1( page 1 is the default page), at a time only one page is visible so we can move only through that ring control present on page 1 and to come back to page 1 from all other pages there is button "go back" on all other 5 pages, everything is working fine for 5 pages but when after going on page 6 and then if i press go back button instead of going back to page 1 program hangs and one more thing that i noticed is after stopping the program the page 6 becomes the default page( which otherwise is page1) i dont know why this is happening.
    I am attaching the snippet of the code which executes when i press go back button.
    one more thing that i am not getting here is when i checked the program through step execution, the last property node( page6 ) that is executing first after that it goes to first property node and then it goes in sequence, this also i want to how is this happening.
    Solved!
    Go to Solution.
    Attachments:
    tab page property node.png ‏43 KB

    I think you would be better off just to use your array and turn on/off the necessary tabs instead of explicity setting each property every iteration.
    Attached is one example.
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
    Attachments:
    set visible tabs.png ‏56 KB

  • OMF export for Pyramix and ProTools not working correctly

    I am exporting OMF files of very simple timelines (30 second promos) for an audio guy based in another part of the country to do audio post.
    He is using Pyramix 7.1.10 and ProTools 9.1, while I'm outputting from Premiere 6.0.1
    The problem is that when he imports the .OMF (which is exported 24bit, trimmed audio, encapsulated files), one leg of the music track is always missing
    This happens the same in both ProTools and Pyramix
    Has anyone else had this happen?  Am I missing something? Is there a workaround?
    All help appreciated
    Thanks
    jON

    I am a post audio mixer working in ProTools, and I have the same issue, just a little more complicated.
    The editors I work with handle a variety of projects, most of which use sound shot with EFP cameras.  The audio recorded on these cameras is "stereo" in the sense that there are indeed 2 tracks as a single interleaved file, however, the content is dual mono, with the 2 tracks either being 2 lav mics, or a lav and the camera mic.
    Is there any way in Premiere that this can be put onto 2 mono tracks, that are then exported as mono tracks, rather than being doubled up in the ProTools session?  Adaptive tracks don't seem to work in this situation.  The editors have tried a variety of things, none of which seem to make a difference.
    Also, regarding stereo music ... that too has been exported to me as a mono file, even though it was supposedly put onto a stereo track in Premiere.
    Thanks for any insights.

  • The select with for all entries is not working correctly

    IF NOT i_ekko_ekpo[] IS INITIAL.
        SELECT ebeln
               ebelp
               zekkn
               vgabe
               bewtp
               menge
               bpmng
               shkzg
               INTO TABLE i_ekbe
               FROM ekbe
               FOR ALL ENTRIES IN i_ekko_ekpo
               WHERE ebeln EQ i_ekko_ekpo-ebeln.
                AND ebelp EQ i_ekko_ekpo-ebelp.
        IF sy-subrc EQ 0.
          SORT i_ekbe.
        ENDIF.
      ENDIF.
    I have a PO with 2 line items in i_ekko_ekpo. In EKBE, I have 49 recs for this PO and this select is returning only 13 recs.
    I tried by commenting EBELP and still the same result.
    Thanks
    Kiran
    Edited by: kiran dasari on May 22, 2009 9:56 PM

    Hi Sudhi, I added these now but still no charm
        SELECT ebeln
               ebelp
               zekkn
               vgabe
               bewtp
               menge
               bpmng
               shkzg
               INTO TABLE i_ekbe
               FROM ekbe
               FOR ALL ENTRIES IN i_ekko_ekpo
               WHERE ebeln EQ i_ekko_ekpo-ebeln
                 AND ebelp EQ i_ekko_ekpo-ebelp
                 AND zekkn GE '00'
                 AND vgabe IN ('1','2').
    And as per your note: in the 13 entries, am having duplicate also. This is something weird for me now.
    Any more clues.
    Thanks
    Kiran

  • Sorting not working correctly for date field in alv report

    Hi All,
    My report displays many rows also containing date type fields of bldat,budat .
    When I sort the report selecting field of type bldat budat the sorting is not correct for the year.
    Ex:
    Invoice doc dat
    01-25-2011
    01-21-2011
    02-02-2011
    10-25-2010
    11-20-2010
    If I use ascending then it is sorted as :
    Invoice doc dat
    01-21-2011
    01-25-2011
    02-02-2011
    10-20-2010
    10-25-2010
    Why the sorting is not working correct for year.(2010 records should have been first).
    The field wa_tab-bldat is of type char10.
    It is populated as wa_tab-bldat = bsak-bldat.
    Kindly suggest what can be done.

    The field wa_tab-bldat is of type char10
    Then what it does is correct.
    Refer to type datum...it will work

  • HT1947 Remote for ipad landscape orientation not working in ios 7

    Remote for ipad landscape orientation not working in ios 7

    See this thread: remote app rotation locked in portrait orientation after iOS 7 upgrade
    It is a discussion only - no helpful hints.  Appears to be a bug for sure.

  • Email pushing not working correctly for office email - 3 seperate devices/carriers

    We switched email hosts several months ago and since our email pushing has not worked correctly. Our host/IT guy has been very unwilling to help me through this (I get the pleasure of being the in-house IT source)
    I personally am on AT&T have no problems with the other 3 emails I have set up on my blackberry. However I receive my work account one time a day at roughly 6:15. Another user is on Alltel and he receives spotty emails throughout the day, but his gmail account comes through instantly. The third user is on nextel and he receives his 2-3 times per day.
    I began to think this was an email host issue since the three of us are all on different carriers, until I found out a fourth user, also on nextel, receives his emails fine.
    Users 1-3 are on Outlook 07 on various versions of the Curve. We have all our messages to stay on the server.
    User 4 is on the older nextel blackberry push to talk, and is not on outlook. 
    We do not have an exchange server. Our emails were all set up through our devices.
    Any suggestions? The answers I have received through our carriers is to make sure that our messages are set to be left on the server. Everyone else at the office has given up - but for me this is the quest for the Holy Grail.......I'm determined find the answer!
    Thank you in advance for any suggestions.
    Caitlin Talbot 

    Potential solution for windows for a side-by-side install. This works for me.
    To setup a firefox install side by side so that links from external programs (like email) can open (so you don't get a "Firefox is already running but is not responding" message) do the following.
    The solution entails the use of the -no-remote switch. Don't use it for the default browser. Use it for the non default browser.
    I'll use firefox 3.6 and firefox 4.0 as examples but this should work for future versions.
    + Install firefox 3.6 and Firefox 4.0 in different directories. Eg.
    C:\Program Files\Mozilla Firefox\firefox.exe
    C:\Program Files\Mozilla Firefox 4\firefox.exe
    + Open profile manager. Start > Run : firefox.exe -ProfileManager
    + In profile manager create Two Profiles.
    firefox3.6
    firefox4
    + In profile manager select firefox 4 as your default (assuming you want to default to the latest) and tick "Don't ask at startup"
    + Create two windows shortcuts.
    * General: Mozilla Firefox 4 (default). Shortcut > Target: "C:\Program Files\Mozilla Firefox 4\firefox.exe". Shortcut > Start In: "C:\Program Files\Mozilla Firefox 4"
    * General: Mozilla Firefox 3.6. Shortcut > Target: "C:\Program Files\Mozilla Firefox\firefox.exe" -p firefox3.6 -no-remote. Shortcut > Start In: "C:\Program Files\Mozilla Firefox"
    That's it. Links from external programs should now open in your default browser.
    Further details see. [http://kb.mozillazine.org/Opening_a_new_instance_of_your_Mozilla_application_with_another_profile Opening a new instance of your Mozilla application with another profile]

  • My dvd slot for imac10,1 does not work. It rejects the disc. Problem after reinstall of backup from hdd.

    My dvd slot for imac10,1 does not work. I had a new harddrive installed in November and the MacStore installed my backups from an external harddrive. I do not use it other than to upload programs, so I have not tried using it until tax season, but it rejects the disc. The ata file indicates no dvd firmware, but the serial-ata does indicate firmware for a dvdrw. What might I do about this to bring the dvd back, least expensive to most?

    Yesterday I started having the same problem. Can read disc (play movies and music) but blank disk are ejected or idvd cannot see the blank disk. I have a almost 12 month old 27" i7 imac.

  • In SSRS , after exporting report in excel,wrap text property for cell and freeze column for SSRS table header not working in Excel

    I am working no one SSRS my table headers are freeze cangrow property is false and my report is working perfect while rendering data on RDL and i want same report after exporting in Excel also , i want my table header to be freeze and wrap text property
    to work after exporting in my report in excel but its not working ,is there any solution ? any patch ? any other XML code for different rendering ? 

    Hi Amol,
    According to your description, you find the wrap text property and fix column is not working after exporting into Excel. Right?
    In Reporting Services, when exporting to excel file, it has limitation for textbox.
    Text boxes are rendered within one Excel cell. Font size, font face, decoration, and font style are the only formatting that is supported on individual text within an Excel cell.
    Excel adds a default padding of approximately 3.75 points to the left and right sides of cells. If a text box’s padding settings are less than 3.75 points and is just barely wide enough to accommodate the text, the text may wrap in Excel.
    In this scenario, it supposed to be wrap text unless you merge cells. If cells are merged, word-wrap does not work correctly. If any merged cells exist on a row where a text box is rendered with the
    AutoSize property, autosize will not work. For the Fix Data Property, it can't be working in Excel. These are features when exporting to Excel. We can't change it because it's by design.
    Reference:
    Exporting to Microsoft Excel (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • I want to reset my ipod touch 4th gen but i have forgotten the restrictions passcode and for some reason its not working on my laptop on itunes and the restore thing wont work! any help?

    I want to reset my ipod touch 4th gen but i have forgotten the restrictions passcode and for some reason its not working on my laptop on itunes and the restore thing wont work! any help?

    Make sure you have the Current Version of iTunes Installed on your computer
    iTunes free download from www.itunes.com/download
    Then See Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...  Be sure to Follow ALL the Steps...
    Take your time... Pay particular attention to Steps 3 and 4.
    After you have Recovered your Device...Re-Sync your Content
    Note:
    To remove a forgotten Restrictions passcode you will need to  Restore the Device as New...
    OR... From a Backup created Before the Restrictions Code was set....

  • Auto To working for one material and not working for other material

    Hi,
    Hope everybody is doing fine.
    I have configured the auto TO. Its working fine for one material and not working for the other material. I checked the material master and wm 1,2 views have the same fileds / values. What could be wrong?
    I didn't setup the back ground processing job. Is that is affecting it?
    thanks for any help.
    regrads,
    KHAN

    Thnaks,
    You are right but then what could be wrong? Its working for one material and not working for otehr material? Any clue?
    Appreciate your time charlie

  • My new Dell PC running Windows 8 does not recognize my iPad or iPhone. Worked OK for iPhone for months but would not work for new iPad.  I removed /relaoded iTunes and now it won't recognize either iPad or iPhone.

    My new Dell PC running Windows 8 does not recognize my iPad or iPhone. Worked OK for iPhone for months but would not work for new iPad.  I removed /relaoded iTunes and now it won't recognize either iPad or iPhone. Got any suggestions?

    Hi there Lizabethfromaz,
    You may find the troubleshooting steps in the article below helpful.
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/ts1538
    -Griff W. 

  • Link for territory mgmt is not working

    Hi All,
    We have territory management configured for three custom attributes.
    Link for territory management is not working for territory assignment block on account overview screen.
    Any hint how we can solve this issue?
    Thanks and Regards,
    Gauri.

    How are you resetting the password?
    Resetting User Password in Lion, Mountain Lion & Mavericks
    Boot into your Recovery Partition by hold down the Command and R keys whilst booting.
    When the Recovery screen appears, go to the Utilities menu and open Terminal.
    In Terminal, type:
    resetpassword
    ...a small app will open and allow you to choose the user for whom you want to change the password. If you are the admin, be certain that you choose your admin user. Type in your new password twice and give yourself a good hint. Click OK (or Done or whatever) and reboot, enjoying the use of your new, hopefully memorable, password.
    Good luck,
    Clinton

Maybe you are looking for

  • Printer Sharing Works in One Direction, Not the Other

    I recently set up a MacBook for my mom. She also has an older iMac with a Canon Pixma IP90 attached, so I tried to set up printer sharing, which should allow her to print from the MacBook without switching the USB cable around. Printing from the iMac

  • MRP Control of a Material

    Can we control planning for a material in such a way that it should be planned for some sales order items while some other sales order items having same material must not be planned. This has to be controlled on a sales order item status. if the stat

  • Send a message from outlook with your pin from your blackberry

    is the a way to send a message from outlook with your pin from your blackberry I want to input my friends pin in outlook and send a message that way. 

  • Mplayer or kmplayer won't play videos (solved)

    Mplayer hangs after video select and cannot be exited in Kde. Kernel 2.6.13.4-1. Must reboot to eliminate mplayer from kde display. Kmplayer does not play video either but can be deselected. Videos OK in kaboodle and noatun displays. Error message du

  • My tabs randomly become scrambled and encrypted in what appears to be mandarin? What is going on???

    When I have my web browser open for some moderate time period, suddenly the "web-page tabs" become scrambled and have an overwriting text which appears to be Mandarin or Japanese. The red "close (x)" button on the tab as well as the plus (+) to open