diff --git a/src/data/CCFun_vec.ml b/src/data/CCFun_vec.ml index 29af2859..65947ee9 100644 --- a/src/data/CCFun_vec.ml +++ b/src/data/CCFun_vec.ml @@ -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. diff --git a/src/data/CCFun_vec.mli b/src/data/CCFun_vec.mli index bff63d96..6d4a55f6 100644 --- a/src/data/CCFun_vec.mli +++ b/src/data/CCFun_vec.mli @@ -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