Jump to content

Recommended Posts

Posted

Went looking for a FIFO queue there are a few examples here on the forum but I didn't like the complexit/lack of flexibility in what I found

The Queue Ive implemented uses a single dimension array  set up as a circular buffer

The position and Item Count are stored in an extra slot of the array inside a 'DllStruct'

Convenience Functions are included

FifoQueue_Create($iSlots) ;Initialize the Queue

Func FifoQueue_($eFQ, ByRef $aQ) ;For Status Functions - (So you don't have to supply $vOut)

Available operations:

$eFQ_Create = 0, $eFQ_Push, $eFQ_Peek, $eFQ_Pop, $eFQ_IsEmpty, $eFQ_IsFull, $eFQ_Count, $eFQ_Empty, $eFQ_IsInit
  Reveal hidden contents

Example (With Debug function)

  Reveal hidden contents

 

Posted

Here is a second version with Redim supported

Note redim only works when items are in the array if you are making it larger

Queue needs to be empty to redim smaller.

It also BitXORs the number of slots with 0xF1F0 to be a bit more robust with checking if the Queue array is valid

  Reveal hidden contents

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...