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

Implement empty!() for CircularBuffer and add CircularBuffer to docs #314

Closed
KadeG opened this issue Aug 9, 2017 · 5 comments
Closed

Implement empty!() for CircularBuffer and add CircularBuffer to docs #314

KadeG opened this issue Aug 9, 2017 · 5 comments

Comments

@KadeG
Copy link
Contributor

KadeG commented Aug 9, 2017

empty!(CircularBuffer) would be nicer to use than recreating it. CircularBuffer has auto-eviction while CircularDeque does not, so it warrants an entry in the docs.

@kmsquire
Copy link
Member

Thanks for creating this issue. Do feel up to submitting a pull request?

@KadeG
Copy link
Contributor Author

KadeG commented Aug 11, 2017

I'd love to. It may be terrible- I'm new to this.

@kmsquire
Copy link
Member

No worries--I and others will try to give good feedback. Give it a try!

@KadeG
Copy link
Contributor Author

KadeG commented Aug 18, 2017

CircularDeque's empty!() does not seem to actually delete anything. Is this faster than actually deleating things like in array.jl using _deleteend!(a::Vector, delta::Integer) = ccall(:jl_array_del_end, Void, (Any, UInt), a, delta) ?

Since CircularBuffer doesn't have n first, and last to reset, would recreating the buffer as an empty vector of type T work?

function Base.empty!(cb::CircularBuffer)
    cb.buffer = typeof(cb.buffer)[]
    cb
end

Sidenote: CircularDeque's docstring Create a double-ended queue of maximum capacity 'n' is a bit confusing because n is used as the number of elements currently contained in empty!(), not the maximum capacity.

@KadeG
Copy link
Contributor Author

KadeG commented Aug 19, 2017

This is now #317 . Closing the issue.

@KadeG KadeG closed this as completed Aug 19, 2017
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

2 participants