H
Harald Kirsch
Hi,
asked to write a buffer implementation, I would
go for an array a read pointer and a write pointer
and would just wrap them around at the end of the
array, making sure that they don't overtake each
other.
Writing and reading would be possible at any time
if the buffer is not full or resp. empty.
Compare this with the tedious and confusing
(my opinion) interface of java.nio.Buffer design:
When you want to write to the buffer, do you first
do a flip(), clear() or rewind() or do you first
scratch your head and wonder which one now?
Does remaining() tell you how much room there is or
how much data is available?
Can anyone give me some reason why they choose this
buffer interface and implementation? It probably
would help me to understand when to do what.
Thanks,
Harald.
asked to write a buffer implementation, I would
go for an array a read pointer and a write pointer
and would just wrap them around at the end of the
array, making sure that they don't overtake each
other.
Writing and reading would be possible at any time
if the buffer is not full or resp. empty.
Compare this with the tedious and confusing
(my opinion) interface of java.nio.Buffer design:
When you want to write to the buffer, do you first
do a flip(), clear() or rewind() or do you first
scratch your head and wonder which one now?
Does remaining() tell you how much room there is or
how much data is available?
Can anyone give me some reason why they choose this
buffer interface and implementation? It probably
would help me to understand when to do what.
Thanks,
Harald.