Results 1 to 5 of 5

Thread: Question about a Queue object

  1. #1
    Frenzied Member
    Join Date
    Jul 06
    Location
    MI
    Posts
    1,520

    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
    Burning Member Niya's Avatar
    Join Date
    Nov 11
    Posts
    3,094

    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 | Create Sortable BindingList(not mine) | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading


    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

  3. #3
    Frenzied Member
    Join Date
    Jul 06
    Location
    MI
    Posts
    1,520

    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
    Burning Member Niya's Avatar
    Join Date
    Nov 11
    Posts
    3,094

    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 | Create Sortable BindingList(not mine) | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading


    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

  5. #5
    Frenzied Member Evil_Giraffe's Avatar
    Join Date
    Aug 02
    Location
    Suffolk, UK
    Posts
    1,876

    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
  •