Proto/Env: remove {Set,Map}.find
Also replace all the function raising `Not_found` by their `_opt` version.
This commit is contained in:
parent
48cc2e9928
commit
afb1e0f260
@ -56,18 +56,12 @@ module type SET = sig
|
||||
val partition: (elt -> bool) -> t -> t * t
|
||||
val cardinal: t -> int
|
||||
val elements: t -> elt list
|
||||
val min_elt: t -> elt
|
||||
val min_elt_opt: t -> elt option
|
||||
val max_elt: t -> elt
|
||||
val max_elt_opt: t -> elt option
|
||||
val choose: t -> elt
|
||||
val choose_opt: t -> elt option
|
||||
val split: elt -> t -> t * bool * t
|
||||
val find: elt -> t -> elt
|
||||
val find_opt: elt -> t -> elt option
|
||||
val find_first: (elt -> bool) -> t -> elt
|
||||
val find_first_opt: (elt -> bool) -> t -> elt option
|
||||
val find_last: (elt -> bool) -> t -> elt
|
||||
val find_last_opt: (elt -> bool) -> t -> elt option
|
||||
val of_list: elt list -> t
|
||||
end
|
||||
@ -95,18 +89,12 @@ module type MAP = sig
|
||||
val partition: (key -> 'a -> bool) -> 'a t -> 'a t * 'a t
|
||||
val cardinal: 'a t -> int
|
||||
val bindings: 'a t -> (key * 'a) list
|
||||
val min_binding: 'a t -> (key * 'a)
|
||||
val min_binding_opt: 'a t -> (key * 'a) option
|
||||
val max_binding: 'a t -> (key * 'a)
|
||||
val max_binding_opt: 'a t -> (key * 'a) option
|
||||
val choose: 'a t -> (key * 'a)
|
||||
val choose_opt: 'a t -> (key * 'a) option
|
||||
val split: key -> 'a t -> 'a t * 'a option * 'a t
|
||||
val find: key -> 'a t -> 'a
|
||||
val find_opt: key -> 'a t -> 'a option
|
||||
val find_first: (key -> bool) -> 'a t -> key * 'a
|
||||
val find_first_opt: (key -> bool) -> 'a t -> (key * 'a) option
|
||||
val find_last: (key -> bool) -> 'a t -> key * 'a
|
||||
val find_last_opt: (key -> bool) -> 'a t -> (key * 'a) option
|
||||
val map: ('a -> 'b) -> 'a t -> 'b t
|
||||
val mapi: (key -> 'a -> 'b) -> 'a t -> 'b t
|
||||
|
@ -105,18 +105,12 @@ module type SET = sig
|
||||
val partition: (elt -> bool) -> t -> t * t
|
||||
val cardinal: t -> int
|
||||
val elements: t -> elt list
|
||||
val min_elt: t -> elt
|
||||
val min_elt_opt: t -> elt option
|
||||
val max_elt: t -> elt
|
||||
val max_elt_opt: t -> elt option
|
||||
val choose: t -> elt
|
||||
val choose_opt: t -> elt option
|
||||
val split: elt -> t -> t * bool * t
|
||||
val find: elt -> t -> elt
|
||||
val find_opt: elt -> t -> elt option
|
||||
val find_first: (elt -> bool) -> t -> elt
|
||||
val find_first_opt: (elt -> bool) -> t -> elt option
|
||||
val find_last: (elt -> bool) -> t -> elt
|
||||
val find_last_opt: (elt -> bool) -> t -> elt option
|
||||
val of_list: elt list -> t
|
||||
end
|
||||
@ -144,18 +138,12 @@ module type MAP = sig
|
||||
val partition: (key -> 'a -> bool) -> 'a t -> 'a t * 'a t
|
||||
val cardinal: 'a t -> int
|
||||
val bindings: 'a t -> (key * 'a) list
|
||||
val min_binding: 'a t -> (key * 'a)
|
||||
val min_binding_opt: 'a t -> (key * 'a) option
|
||||
val max_binding: 'a t -> (key * 'a)
|
||||
val max_binding_opt: 'a t -> (key * 'a) option
|
||||
val choose: 'a t -> (key * 'a)
|
||||
val choose_opt: 'a t -> (key * 'a) option
|
||||
val split: key -> 'a t -> 'a t * 'a option * 'a t
|
||||
val find: key -> 'a t -> 'a
|
||||
val find_opt: key -> 'a t -> 'a option
|
||||
val find_first: (key -> bool) -> 'a t -> key * 'a
|
||||
val find_first_opt: (key -> bool) -> 'a t -> (key * 'a) option
|
||||
val find_last: (key -> bool) -> 'a t -> key * 'a
|
||||
val find_last_opt: (key -> bool) -> 'a t -> (key * 'a) option
|
||||
val map: ('a -> 'b) -> 'a t -> 'b t
|
||||
val mapi: (key -> 'a -> 'b) -> 'a t -> 'b t
|
||||
|
@ -435,7 +435,7 @@ let empty_map
|
||||
let map_get
|
||||
: type key value. key -> (key, value) map -> value option
|
||||
= fun k (module Box) ->
|
||||
try Some (Box.OPS.find k (fst Box.boxed)) with Not_found -> None
|
||||
Box.OPS.find_opt k (fst Box.boxed)
|
||||
|
||||
let map_update
|
||||
: type a b. a -> b option -> (a, b) map -> (a, b) map
|
||||
|
@ -15,8 +15,9 @@ let get_proposals ctxt =
|
||||
~init:Protocol_hash.Map.empty
|
||||
~f:(fun (proposal, _delegate) acc ->
|
||||
let previous =
|
||||
try Protocol_hash.Map.find proposal acc
|
||||
with Not_found -> 0l in
|
||||
match Protocol_hash.Map.find_opt proposal acc with
|
||||
| None -> 0l
|
||||
| Some x -> x in
|
||||
Lwt.return (Protocol_hash.Map.add proposal (Int32.succ previous) acc))
|
||||
|
||||
let clear_proposals ctxt =
|
||||
|
Loading…
Reference in New Issue
Block a user