• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

this is dumb i know

Joined
Dec 15, 2009
Messages
1,387
Reaction score
236


how can I only retrieve an element from var arrays one at a time in an arranged number?

no math.random pls
 
Watching from above
Legend
Joined
Apr 9, 2004
Messages
3,828
Reaction score
752
Ultimately the best way for you to iterate over the array depends on what kind of content you have in there - e.g. whether they're meant to repeat or be used only once, but here's one approach assuming messages are something that appear at random times and do get shown only once.
 
Joined
Dec 15, 2009
Messages
1,387
Reaction score
236
Ultimately the best way for you to iterate over the array depends on what kind of content you have in there - e.g. whether they're meant to repeat or be used only once, but here's one approach assuming messages are something that appear at random times and do get shown only once.
How can make it infinite loop? Haven't check the codes tho

--
am looking for something that works like this


however, I don't wish to include an additional script. Looking for a pure direct jquery method.
 
Last edited:
Watching from above
Legend
Joined
Apr 9, 2004
Messages
3,828
Reaction score
752
Just code that damn ring buffer yourself, it'll do good for you. ;)

For an extremely naive solution though that will work in 10 seconds (that you should not consider a proper implementation and never quote on me telling you to write it like that), on every iteration just shift out the first element from the array and when you're done with it just push it back to the end of the array. (like that: )

Let me repeat, it's a bad solution in the general case because it has has terrible performance implications AND it's extremely vulnerable to concurrency issues should it be implemented on a platform that supports concurrent executions.
 
Joined
Dec 15, 2009
Messages
1,387
Reaction score
236
Just code that damn ring buffer yourself, it'll do good for you. ;)

For an extremely naive solution though that will work in 10 seconds (that you should not consider a proper implementation and never quote on me telling you to write it like that), on every iteration just shift out the first element from the array and when you're done with it just push it back to the end of the array. (like that: )

Let me repeat, it's a bad solution in the general case because it has has terrible performance implications AND it's extremely vulnerable to concurrency issues should it be implemented on a platform that supports concurrent executions.



i bet this one is better :) right?
 
Watching from above
Legend
Joined
Apr 9, 2004
Messages
3,828
Reaction score
752
Better in what terms? Sure it can be void of the theoretical performance issue depending on the implementation of jQuery's find and/or CSS selectors - in this case I doubt it is.

What's more troubling to me is that now your responsibilities are all messed up as you're using the view as data storage, and note this is what you should worry about rather than what I said above if you want to write better code. Besides, it will break as soon as you add or remove elements or fiddle with timings so you have a maintainability issue there. It's a pretty sweet hack you have there though I'll give you that :)
 
Back
Top