Here's a simple implementation of a FIFO queue in Matlab using a cell array:
main.m2213 chars83 lines
To use the fifoQueue class, simply create an instance of the class with the desired capacity:
main.m25 chars2 lines
You can then push elements onto the queue using the push
method:
main.m51 chars4 lines
You can get the front element of the queue using the front
method:
main.m32 chars2 lines
You can pop an element from the front of the queue using the pop
method:
main.m31 chars2 lines
And you can get the back element of the queue using the back
method:
main.m30 chars2 lines
Finally, you can check if the queue is empty or full using the isempty
and isfull
methods, respectively:
main.m64 chars3 lines
gistlibby LogSnag