Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elastic, Sliceable Buffer Queue #5

Closed
hxtk opened this issue Feb 4, 2018 · 1 comment
Closed

Elastic, Sliceable Buffer Queue #5

hxtk opened this issue Feb 4, 2018 · 1 comment

Comments

@hxtk
Copy link
Owner

hxtk commented Feb 4, 2018

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.

@hxtk
Copy link
Owner Author

hxtk commented Feb 4, 2018

This issue is on hold until we have evaluated abonander/buf_redux.

@hxtk hxtk closed this as completed Feb 4, 2018
hxtk added a commit that referenced this issue Feb 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant