You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need this data structure to handle the implementation of non-destructive lookahead for Issues #3 and #4.
Requirements
Elasticity
Fixed Minimum Capacity
The buffer cannot be allowed to shrink arbitrarily small or else we have defeated the purpose of buffered reads, especially when reading files or network streams.
Note: This does not mean the buffer must always be filled to capacity
Stretch
The buffer must be able to accommodate more data than its capacity when requested. By principle of least astonishment, this should require a special function and the default behavior should be to respect the capacity.
Contraction
To avoid memory bloat, after the buffer has been "stretched", future destructive calls should shrink its capacity until it has returned to its minimum capacity.
Sliceability
trait BufRead requires that we return a slice of the filled buffer when a call is made to fill_buf(). We would like to do this in O(1) using the normal slice operation since this will represent nearly all read operations, and the tradeoff is against insertion, which will be O(n) as a result of this decision but will only occur when the buffer is empty or stretch is requested.
Queue
This is self-explanatory: we want to extract values in the same order that they were read.
The text was updated successfully, but these errors were encountered:
We need this data structure to handle the implementation of non-destructive lookahead for Issues #3 and #4.
Requirements
Elasticity
Fixed Minimum Capacity
The buffer cannot be allowed to shrink arbitrarily small or else we have defeated the purpose of buffered reads, especially when reading files or network streams.
Stretch
The buffer must be able to accommodate more data than its capacity when requested. By principle of least astonishment, this should require a special function and the default behavior should be to respect the capacity.
Contraction
To avoid memory bloat, after the buffer has been "stretched", future destructive calls should shrink its capacity until it has returned to its minimum capacity.
Sliceability
trait BufRead
requires that we return aslice
of the filled buffer when a call is made tofill_buf()
. We would like to do this in O(1) using the normalslice
operation since this will represent nearly all read operations, and the tradeoff is against insertion, which will be O(n) as a result of this decision but will only occur when the buffer is empty or stretch is requested.Queue
This is self-explanatory: we want to extract values in the same order that they were read.
The text was updated successfully, but these errors were encountered: