âšī¸ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | FAIL | download_stamp > now() - 6 MONTH | 8.5 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://stackoverflow.com/questions/5465332/c-queue-with-efficient-get-put-of-multiple-elements |
| Last Crawled | 2025-07-31 04:26:14 (8 months ago) |
| First Indexed | 2017-05-24 03:57:04 (8 years ago) |
| HTTP Status Code | 200 |
| Meta Title | stl - C++: Queue with efficient get/put of multiple elements? - Stack Overflow |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | So, I feel like there should be a good, built-in solution for this in C++, but I'm not sure what it is. I need a queue (ideally thread-safe, but I can wrap it in synchronization myself if need be) that handles groups of bytes efficiently - allowing reads/writes of different sizes. so, the interface looks like e.g. int dequeue ( unsigned char *array, int bytesToRead) int enqueue ( unsigned char *array, int bytesToWrite) I can write one myself without too much difficulty, but it seems like this ought to be something that's easily done off the shelf. 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. I'm looking to do this as a drop-in replacement for a current queue implementation that's a performance problem; reading in this implementation is O(N) on the amount of data in the queue. (It's a very naive implementation - every dequeue results in an array copy of the remaining data in the queue.) 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) Is there some other class that I'm not seeing that would suffice? Thanks in advance! |
| Markdown | null |
| Readable Markdown | null |
| Shard | 169 (laksa) |
| Root Hash | 714406497480128969 |
| Unparsed URL | com,stackoverflow!/questions/5465332/c-queue-with-efficient-get-put-of-multiple-elements s443 |