Shezan Baig wrote:
[snip]
I don't think it's defined. It shouldn't really matter - why are you
accessing the buffer directly anyway?
I'm accessing the filebuf. The problem is this: I have a
PersistentQueue implemented over a file. The queue has the following
format on disk:
+--------------------+
| nlr, lrl, npr, lpr | header (num logical records, length)
+--------------------+
| record 1 | first processed record
+--------------------+
| record 2 |
+--------------------+
| ... |
+--------------------+
| record i | last processed record
+--------------------+
| record i + 1 | next pending record (npr = front)
+--------------------+
| ... |
+--------------------+
| record n | last pending record (lpr = back)
+--------------------+
Now, suppose I want to provide iterators:
QueueIter beginProcessed();
QueueIter endProcessed();
QueueIter beginPending();
QueueIter endPending();
Each iterator needs to have its own file representation (e.g., filebuf)
because they are independently incremented and dereferenced (returning
a copy of the current record). If every filebuf pre-fetches 2K of data,
this implementation can be very inefficient. /david