Results 1 to 5 of 5

Thread: Question about a Queue object

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    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...

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Question about a Queue object

    Quote Originally Posted by nbrege View Post
    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    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.

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  5. #5
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Question about a Queue object

    Quote Originally Posted by Niya View Post
    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
  •  



Click Here to Expand Forum to Full Width