-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
empty!() for CircularDeque, add it to docs, add some other missing th…
…ings to docs (#317) * Add empty!() for CircularBuffer. Add circ_buffer.rst to docs. Add circ_buffer.rst and missing priority-queue.rst to index.rst * Add missing CircularDeque functions to docs. * Move * Priority Queue to under * Queue * empty!(cb) = cb.first = 1; empty!(cb.buffer) * Add empty!(cb) test
- Loading branch information
Showing
6 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.. _ref-circular_buffer: | ||
|
||
-------------- | ||
CircularBuffer | ||
-------------- | ||
|
||
The ``CircularBuffer`` type implements a circular buffer of fixed ``capacity`` where new items are pushed to the back of the list, overwriting values in a circular fashion. | ||
|
||
Usage:: | ||
|
||
a = CircularBuffer{Int}(n) # allocate an Int buffer with maximum capacity n | ||
isfull(a) # test whether the buffer is full | ||
isempty(a) # test whether the buffer is empty | ||
empty!(a) # reset the buffer | ||
capacity(a) # return capacity | ||
length(a) # get the number of elements currently in the buffer | ||
size(a) # same as length(a) | ||
push!(a, 10) # add an element to the back and overwrite front if full | ||
unshift!(a, 10) # add an element to the front and overwrite back if full | ||
append!(a, [1, 2, 3, 4]) # push at most last `capacity` items | ||
convert(Vector{Float64}, a) # convert items to type Float64 | ||
eltype(a) # return type of items | ||
a[1] # get the element at the front | ||
a[end] # get the element at the back |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters