fix(funvec): expose pop, fix off by one error

close #241
This commit is contained in:
Simon Cruanes 2018-12-11 22:57:06 -06:00
parent 197b4e7f1b
commit f8d9e33900
2 changed files with 6 additions and 2 deletions

View file

@ -236,10 +236,10 @@ let pop_ i (m:'a t) : 'a * 'a t =
let pop_exn (v:'a t) : 'a * 'a t =
if v.size=0 then failwith "Fun_vec.pop_exn";
pop_ v.size v
pop_ (v.size-1) v
let pop (v:'a t) : ('a * 'a t) option =
if v.size=0 then None else Some (pop_ v.size v)
if v.size=0 then None else Some (pop_ (v.size-1) v)
let iteri ~f (m : 'a t) : unit =
(* basically, a 32-way BFS traversal.

View file

@ -72,6 +72,10 @@ val get_exn : int -> 'a t -> 'a
val pop_exn : 'a t -> 'a * 'a t
(** Pop last element. *)
val pop : 'a t -> ('a * 'a t) option
(** Pop last element.
@since NEXT_RELEASE *)
val iter : f:('a -> unit) -> 'a t -> unit
val iteri : f:(int -> 'a -> unit) -> 'a t -> unit