list Node.InsertBefore and Node.InsertAfter broken

About Monkey 2 Forums Monkey 2 Development list Node.InsertBefore and Node.InsertAfter broken

This topic contains 5 replies, has 3 voices, and was last updated by  skn3 2 years, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #4513

    skn3
    Participant

    Looks like insert before/after are broken? Unless I am doing it wrong?

    #4521

    Jesse
    Participant

    Mark, I saw that you modified the List to work with skn3 Post. My question is, Is the only way to use InsertBefore or InsertAfter by using nodes with in the list? I tried to add a removed node to it and it failed. produced an endless for loop. I tried it before the current modifications and after the modifications with same results.

    [/crayon]
    #4523

    Mark Sibly
    Keymaster

    Not quite sure what you’re expecting this to do – once you remove item1.node, it’s no longer in a list so inserting things before/after it doesn’t have a lot of meaning. Also, note that nodes can only be in one list at a time.

    Incidentally, I don’t get an endless loop here (with new List), both item1 and item2 just ‘disappear’ as expected, as you a) remove node1 (effectively ‘moving’ it from the list to ‘no list’) then insert node2 before node1 (so it’s also gone!).

    But again, I recommend avoiding lists altogether if possible – sticks to Stacks, sort them if necessary, whatever. Lists are slow, memory intensive and just generally icky, as the above demonstrates.

    Still, probably my fault for semi-popularizing list abuse like this in the first place!

    #4527

    Jesse
    Participant

    .

    #4528

    Jesse
    Participant

    Thanks, I was trying to do some some experimenting and wasn’t sure if it was doable or not. I was just wondering if I could move a node from one list to another by doing it that way.

    another question:
    are linked Lists slow or just this module? I know arrays are faster but was wonder. I guess I could do some tests.

    #4532

    skn3
    Participant

    Didn’t realise that the Stack in monkey2 had been fleshed out so much, compared to monkey1/blitz! Very helpful!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.