S
Shailesh Humbad
I wrote a simple, but proprietary queue class that efficiently
enqueues and dequeues arbitrary length byte arrays. I would like to
replace it with an STL container if the performance overhead is not
too high. Currently, I am thinking of replacing it like shown below,
but it is not efficient due to repeated function calls to "push". Can
anyone with more STL experience show a better way to use it, if there
is one?
// CUSTOM QUEUE
// receive data from network into byte array
iBytesReceived = recv(destinationBuffer)
// store it in the queue in a single pass
myCustomQueue.Enqueue(destinationBuffer, iBytesReceived)
// STL QUEUE (slower)
// receive data from network into byte array
iBytesReceived = recv(destinationBuffer)
// store it in the queue using push
for(int i = 0; i < iBytesReceived; i++) {
my_STL_Queue.push(destinationBuffer);
}
enqueues and dequeues arbitrary length byte arrays. I would like to
replace it with an STL container if the performance overhead is not
too high. Currently, I am thinking of replacing it like shown below,
but it is not efficient due to repeated function calls to "push". Can
anyone with more STL experience show a better way to use it, if there
is one?
// CUSTOM QUEUE
// receive data from network into byte array
iBytesReceived = recv(destinationBuffer)
// store it in the queue in a single pass
myCustomQueue.Enqueue(destinationBuffer, iBytesReceived)
// STL QUEUE (slower)
// receive data from network into byte array
iBytesReceived = recv(destinationBuffer)
// store it in the queue using push
for(int i = 0; i < iBytesReceived; i++) {
my_STL_Queue.push(destinationBuffer);
}