"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Assuming your question is not related to threads (since nothing of what you said in this ... thread relates to threads), my understanding is that you need a queue of items, in which each item is itself a list of successive actions to be performed together one after the other when a certain state is reached. This is not really a queue of queues, but rather a queue of lists. If such is the case, then an AoA is probably what you need. Something like this:
To add an item to the queue: push @queue, [7, 3, 0, 9];Which results in the following data structure:
To retrieve and remove a list of actions from the queue:
Now, $action_ref is [1, 2, 3], i.e. a reference to an anonymous array containing (1, 2, 3). You can now retrieve the actions one after the other from that anonymous array. For example, if you want to list the actions you've just dequeued: print $_, " - " foreach @$action_ref; # prints: 1 - 2 - 3 -Is this what you need? In reply to Re^3: How to create a two dimensional queue in Perl
by Laurent_R
|
|