mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 03:35:30 -05:00
Merge pull request #151 from quicquid/ccfqueue-bugfix
bugfix for `CCFQueue.take_back_exn` : wrong exception
This commit is contained in:
commit
9a2dab6802
1 changed files with 9 additions and 1 deletions
|
|
@ -131,6 +131,10 @@ let take_front q =
|
||||||
try Some (take_front_exn q)
|
try Some (take_front_exn q)
|
||||||
with Empty -> None
|
with Empty -> None
|
||||||
|
|
||||||
|
(*$T
|
||||||
|
take_front empty = None
|
||||||
|
*)
|
||||||
|
|
||||||
let take_front_l n q =
|
let take_front_l n q =
|
||||||
if n<0 then (
|
if n<0 then (
|
||||||
invalid_arg "take_back_l: cannot take negative number of arguments"
|
invalid_arg "take_back_l: cannot take negative number of arguments"
|
||||||
|
|
@ -161,7 +165,7 @@ let take_front_while p q =
|
||||||
|
|
||||||
let rec take_back_exn : 'a. 'a t -> 'a t * 'a
|
let rec take_back_exn : 'a. 'a t -> 'a t * 'a
|
||||||
= fun q -> match q with
|
= fun q -> match q with
|
||||||
| Shallow Zero -> invalid_arg "FQueue.take_back_exn"
|
| Shallow Zero -> raise Empty
|
||||||
| Shallow (One x) -> empty, x
|
| Shallow (One x) -> empty, x
|
||||||
| Shallow (Two (x,y)) -> _single x, y
|
| Shallow (Two (x,y)) -> _single x, y
|
||||||
| Shallow (Three (x,y,z)) -> Shallow (Two(x,y)), z
|
| Shallow (Three (x,y,z)) -> Shallow (Two(x,y)), z
|
||||||
|
|
@ -185,6 +189,10 @@ let take_back q =
|
||||||
try Some (take_back_exn q)
|
try Some (take_back_exn q)
|
||||||
with Empty -> None
|
with Empty -> None
|
||||||
|
|
||||||
|
(*$T
|
||||||
|
take_back empty = None
|
||||||
|
*)
|
||||||
|
|
||||||
let take_back_l n q =
|
let take_back_l n q =
|
||||||
if n<0 then (
|
if n<0 then (
|
||||||
invalid_arg "take_back_l: cannot take negative number of arguments"
|
invalid_arg "take_back_l: cannot take negative number of arguments"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue