Jump to content




How do I remove gaps in an ordered list


  • You cannot reply to this topic
22 replies to this topic

#21 Termanater13

  • Members
  • 64 posts

Posted 29 April 2014 - 07:00 PM

View PostLyqyd, on 29 April 2014 - 03:23 AM, said:

Also, Bomb Bloke's point above about table.remove touches on an important issue that should be addressed in this post--why is the table sparse in the first place? There are usually better ways of doing things than allowing a table to become sparse when you're going to want to have it be array-like later. I'm having trouble thinking of something that would result in having this sort of problem in the first place.
I'm creating a system that adds a z axis to the x,y of a monitor, where the user can use an arbitrary number for z and it creates a gapless ordered list based on that. this way a perosn can use (1,2,5,63,708) as the z numbers and when the code runs it the order will be (1,2,3,4,5), the values of those numbers will point to a differint place in the bigger table. I have plans that if z is not set the latest to be crated will have the highest z and thus placed ontop of everthing else.

#22 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 30 April 2014 - 01:54 AM

So once the initial table setup is complete, how would the user add any more entries to eg z layer 63 (or even locate a layer with that number), given that you've changed it to 4?

If there won't be any changes after the table is built, or the user isn't intended to be able to browse through the layers, then why bother tracking anything other then the "top-most" entry? Couldn't all the others simply be discarded if covered?

#23 Termanater13

  • Members
  • 64 posts

Posted 30 April 2014 - 06:57 PM

View PostBomb Bloke, on 30 April 2014 - 01:54 AM, said:

So once the initial table setup is complete, how would the user add any more entries to eg z layer 63 (or even locate a layer with that number), given that you've changed it to 4?

If there won't be any changes after the table is built, or the user isn't intended to be able to browse through the layers, then why bother tracking anything other then the "top-most" entry? Couldn't all the others simply be discarded if covered?
the list created by the users code I was going to have avaliable to them, and the one created by this code use it to display each element in the right order. There are probably better ways to get the same result, but right now I am just looking for something to get that part working and that was the best way I could think of. Setting how the second argumemt in the sort function works I may find a different way of doing it, but this will allow me to get it working till I find a better way.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users