Queue, Heads or Tails?
vining
Posts: 4,368
For those that use queue arrays do you have the tail try to catch the head or do you have the head chase the tail?
For me having the tail catch up to the head makes more sense but I was re-working the i!-EquipmentMonitorOut.axi to fix some timing issues and I noticed that it goes the other way which just seems wrong unless you're a dog.
What do others do?
For me having the tail catch up to the head makes more sense but I was re-working the i!-EquipmentMonitorOut.axi to fix some timing issues and I noticed that it goes the other way which just seems wrong unless you're a dog.
What do others do?
0
Comments
Really the same thing, both FIFO but calling the index pointers the opposite names. It just seems backward to me to add new entries to the tail and have the head chase it. The tail should trail and the head should lead.
Only in specific cases i was adding in front of the queue the user commands (from button pushes) and at the
end the automatic requests from a running timeline.
I am not shure how this really achieved my goal but my thought was to rush up the user commands instead
of having them waiting at the end of the tunnel.
Naming them foo and bar would be ok becuase I wouldn't have an pre-conceived expectations of what was what.
Now if it's a multi-level array, I do it the same way out of sheer habit, but, as mentioned, it comes out the same. Either way, you have to add it, remove another, and juggle all the rest to the new order.
I do my queues sliding window style. This involves an array and two integers. When the two integers are equal, the queue is empty. When we push something, we put it in the cell integer A points to and increment integer A. (wrapping back around to the beginning if it reaches the end) When we pop something, we do something with the cell integer B points to and increment B. (again, wrapping it around to the beginning if necessary) So there is a number that chases another number but neither the "head" nor "tail" of the array is special.
This is the way I usually set up my buffers as well, and I also was having trouble understanding what you meant