Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
fix
Commits
c83d9513
Commit
c83d9513
authored
Nov 25, 2021
by
POTTIER Francois
Browse files
Cleanup in CompactQueue.mli.
parent
ceca8d12
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/CompactQueue.mli
View file @
c83d9513
(** This module implements a mutable FIFO queue, like [Queue]. However it has a
more compact representation, storing elements contiguously in an array.
(**This module implements a mutable FIFO queue, like OCaml's [Queue] module.
In comparison with [Queue], it uses a more compact internal representation:
elements are stored contiguously in an array. This has a positive impact on
performance: both time and memory consumption are reduced.
Th
is has a nice impact on per
forma
nce (both time and memory consumption)
when adding and removing
many elements
.
A drawback of this implementation is that some values will be kept alive
longer than necessary, as they might still be reachable from the internal
array.
*)
Th
e implementation is optimized
for
ma
ximum throughput. The internal array
is never shrunk, so a queue that has contained
many elements
in the past
remains large. Furthermore, array slots are not overwritten when elements
are extracted; thus, an element that has appeared in the queue in the past
can remain reachable. These drawbacks are usually acceptable provided that
the queue is thrown away after use.
*)
type
'
a
t
(**
The type of a queue. *)
(**The type of a queue. *)
val
create
:
unit
->
'
a
t
(**
[create
()] creates an empty queue. *)
(**[create()] creates an empty queue. *)
val
is_empty
:
'
a
t
->
bool
(**
[is_empty q] tests whether the queue [q] is empty. *)
(**[is_empty q] tests whether the queue [q] is empty. *)
val
add
:
'
a
->
'
a
t
->
unit
(**
[add x q] adds the element [x] at the end of the queue [q]. *)
(**[add x q] adds the element [x] at the end of the queue [q]. *)
exception
Empty
(**
R
aised when {!take} is applied to an empty queue. *)
(**
[Empty] is r
aised when {!take} is applied to an empty queue. *)
val
take
:
'
a
t
->
'
a
(**
[take q] removes and returns the first element
in
queue [q]
,
or
raises {!Empty} if the queue is empty. *)
(**[take q] removes and returns the first element
of the
queue [q]
.
It
raises {!Empty} if the queue is empty. *)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment