So, I feel like there should be a good, built-in solution for this in C++, but I m not sure what it is.
我需要一个能够高效地处理有色人种——允许不同大小的读写/仪式的问答(最好有读写能力,但我可以同步总结一下。
so, the interface looks like e.g.
//removes the first bytesToRead elements from the front of the queue and places them in array; returns the actual number of bytes dequeued
int dequeue(unsigned char *array, int bytesToRead)
//Adds bytesToWrite elements from array to the end of the queue; does nothing and returns 0 if this would exceed the queue s max size
int enqueue(unsigned char *array, int bytesToWrite)
我可以不遇到太多困难就给我写信,但似乎像这一样,应该很容易地在大陆架外做事。
The best thing in the STL looks like it might be a stringbuf - I d have to pair calls to sgetc/pubseekoff by hand, but it seems like it would work.
我期望这样做,以取代目前的执行问题,即业绩问题;在执行工作中,正在读的是O(N)关于问题中的数据数量。 (这种执行非常冷静,每个频率都导致在座标点的其余数据的阵列本。)
Additional requirements (I can implement these in a wrapper if need be): -I need to be able to specify a maximum size of the buffer -Read operations should retrieve all available data if less data is available than was requested -Write operations should do nothing if the requested write would exceed the maximum size and return a failure indicator
So, my questions: 1) is stringbuf sufficient? Are the read/write operations O(1) relative to the amount of data in the buffer, assuming no resizing is necessary? (obviously, they d potentially be O(n) on the number of items requested.)
2) 是否还有其他几类人认为这还不够?
Thanks in advance!