My initial testing (consisting of running the TestCases several times) reveals the cost of an enqueue/dequeue operation. This consists of both single element vs. multiple element enqueue/dequeue operations. All calls are paired.
The average cost of using the Default Queue is 1.156 usecs per enqueue/dequeue operation. This is pretty decent considering that the Queue is ThreadSafe (i.e. locking is performed). It uses an ArrayList to perform it's duties.
The average cost of using the Fixed Size Queue is 884.0 nsecs per enqueue/dequeue operation. This is a little over half the cost of the DefaultQueue, and it is also ThreadSafe. It directly manipulates an array to perform it's duties.
The array manipulation works like this:
| 1 | 2 | 3 | 4 | 5 | * * S E
S = Start E = End
The current figure shows a queue with 1 element enqueued. When S=E, there are no elements enqueued. The next figure shows what happens when the element is dequeued:
| 1 | 2 | 3 | 4 | 5 | ** SE
The Start pointer moves forward when there are elements to dequeue, and the End pointer moves forward when a new element is enqueued. It is also important to note that the entry where start is is nulled after it is retrieved.
The algorithm wraps the pointers back to 0 when they reach the maximum.
This moving pointer system works quite well, and never requires useless creation of objects or new queue sizes during the life of the Queue.
--
"They that give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." - Benjamin Franklin
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>