|
-
Aug 20th, 2012, 10:47 AM
#1
Thread Starter
Frenzied Member
Question about a Queue object
I have a Queue object with filenames in it. Under certain circumstances I want to move the item at the beginning of the Queue to the end. Will the following line achieve this?
Code:
myFiles.Enqueue(myFiles.Dequeue)
Or is there a better way to do it? Thanks...
-
Aug 20th, 2012, 11:08 AM
#2
Re: Question about a Queue object
 Originally Posted by nbrege
Or is there a better way to do it? Thanks...
Nope....that way is the most elegant way I can think of. Its actually pretty clever.
-
Aug 20th, 2012, 11:50 AM
#3
Thread Starter
Frenzied Member
Re: Question about a Queue object
OK, thanks. I didn't see any direct methods for changing the order of items in a Queue, so that's the only way I could see to do it.
-
Aug 20th, 2012, 07:10 PM
#4
Re: Question about a Queue object
Though I have never used Queue objects before, it would seem its practically identically to a List. A List is easy to treat as a first in first out collection.
-
Aug 21st, 2012, 09:20 AM
#5
Re: Question about a Queue object
 Originally Posted by Niya
Though I have never used Queue objects before, it would seem its practically identically to a List. A List is easy to treat as a first in first out collection.
Except a Queue actually enforces FIFO behaviour, and can have multiple enqueuers and dequeuers working concurrently without additional synchronisation. If your design calls for FIFO behaviour, favour Queues over Lists.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|