mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 03:35:30 -05:00
update some headers, formatting
This commit is contained in:
parent
9e94f002e4
commit
db67b19fe8
6 changed files with 61 additions and 183 deletions
|
|
@ -1,27 +1,6 @@
|
||||||
(*
|
|
||||||
copyright (c) 2013-2014, simon cruanes
|
|
||||||
all rights reserved.
|
|
||||||
|
|
||||||
redistribution and use in source and binary forms, with or without
|
(* This file is free software, part of containers. See file "license" for more details. *)
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer. redistributions in binary
|
|
||||||
form must reproduce the above copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other materials provided with
|
|
||||||
the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*)
|
|
||||||
|
|
||||||
(** {1 Extension to the standard Hashtbl} *)
|
(** {1 Extension to the standard Hashtbl} *)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,5 @@
|
||||||
(*
|
|
||||||
copyright (c) 2013-2014, simon cruanes
|
|
||||||
all rights reserved.
|
|
||||||
|
|
||||||
redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer. redistributions in binary
|
|
||||||
form must reproduce the above copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other materials provided with
|
|
||||||
the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*)
|
|
||||||
|
|
||||||
|
(* This file is free software, part of containers. See file "license" for more details. *)
|
||||||
|
|
||||||
(** {1 Extension to the standard Hashtbl}
|
(** {1 Extension to the standard Hashtbl}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,5 @@
|
||||||
(*
|
|
||||||
copyright (c) 2013-2014, simon cruanes
|
|
||||||
all rights reserved.
|
|
||||||
|
|
||||||
redistribution and use in source and binary forms, with or without
|
(* This file is free software, part of containers. See file "license" for more details. *)
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer. redistributions in binary
|
|
||||||
form must reproduce the above copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other materials provided with
|
|
||||||
the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*)
|
|
||||||
|
|
||||||
(** {1 Extensions of Standard Map} *)
|
(** {1 Extensions of Standard Map} *)
|
||||||
|
|
||||||
|
|
@ -63,11 +41,13 @@ module type S = sig
|
||||||
|
|
||||||
val to_list : 'a t -> (key * 'a) list
|
val to_list : 'a t -> (key * 'a) list
|
||||||
|
|
||||||
val pp : ?start:string -> ?stop:string -> ?arrow:string -> ?sep:string ->
|
val pp :
|
||||||
key printer -> 'a printer -> 'a t printer
|
?start:string -> ?stop:string -> ?arrow:string -> ?sep:string ->
|
||||||
|
key printer -> 'a printer -> 'a t printer
|
||||||
|
|
||||||
val print : ?start:string -> ?stop:string -> ?arrow:string -> ?sep:string ->
|
val print :
|
||||||
key formatter -> 'a formatter -> 'a t formatter
|
?start:string -> ?stop:string -> ?arrow:string -> ?sep:string ->
|
||||||
|
key formatter -> 'a formatter -> 'a t formatter
|
||||||
end
|
end
|
||||||
|
|
||||||
module Make(O : Map.OrderedType) = struct
|
module Make(O : Map.OrderedType) = struct
|
||||||
|
|
@ -83,8 +63,8 @@ module Make(O : Map.OrderedType) = struct
|
||||||
with Not_found -> f None
|
with Not_found -> f None
|
||||||
in
|
in
|
||||||
match x with
|
match x with
|
||||||
| None -> remove k m
|
| None -> remove k m
|
||||||
| Some v' -> add k v' m
|
| Some v' -> add k v' m
|
||||||
|
|
||||||
let add_seq m s =
|
let add_seq m s =
|
||||||
let m = ref m in
|
let m = ref m in
|
||||||
|
|
@ -114,11 +94,11 @@ module Make(O : Map.OrderedType) = struct
|
||||||
Buffer.add_string buf start;
|
Buffer.add_string buf start;
|
||||||
iter
|
iter
|
||||||
(fun k v ->
|
(fun k v ->
|
||||||
if !first then first := false else Buffer.add_string buf sep;
|
if !first then first := false else Buffer.add_string buf sep;
|
||||||
pp_k buf k;
|
pp_k buf k;
|
||||||
Buffer.add_string buf arrow;
|
Buffer.add_string buf arrow;
|
||||||
pp_v buf v
|
pp_v buf v)
|
||||||
) m;
|
m;
|
||||||
Buffer.add_string buf stop
|
Buffer.add_string buf stop
|
||||||
|
|
||||||
let print ?(start="[") ?(stop="]") ?(arrow="->") ?(sep=", ") pp_k pp_v fmt m =
|
let print ?(start="[") ?(stop="]") ?(arrow="->") ?(sep=", ") pp_k pp_v fmt m =
|
||||||
|
|
@ -126,13 +106,14 @@ module Make(O : Map.OrderedType) = struct
|
||||||
let first = ref true in
|
let first = ref true in
|
||||||
iter
|
iter
|
||||||
(fun k v ->
|
(fun k v ->
|
||||||
if !first then first := false else (
|
if !first then first := false
|
||||||
Format.pp_print_string fmt sep;
|
else (
|
||||||
Format.pp_print_cut fmt ()
|
Format.pp_print_string fmt sep;
|
||||||
);
|
Format.pp_print_cut fmt ()
|
||||||
pp_k fmt k;
|
);
|
||||||
Format.pp_print_string fmt arrow;
|
pp_k fmt k;
|
||||||
pp_v fmt v;
|
Format.pp_print_string fmt arrow;
|
||||||
) m;
|
pp_v fmt v)
|
||||||
|
m;
|
||||||
Format.pp_print_string fmt stop
|
Format.pp_print_string fmt stop
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,10 @@
|
||||||
(*
|
|
||||||
copyright (c) 2013-2014, simon cruanes
|
|
||||||
all rights reserved.
|
|
||||||
|
|
||||||
redistribution and use in source and binary forms, with or without
|
(* This file is free software, part of containers. See file "license" for more details. *)
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer. redistributions in binary
|
|
||||||
form must reproduce the above copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other materials provided with
|
|
||||||
the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*)
|
|
||||||
|
|
||||||
(** {1 Extensions of Standard Map}
|
(** {1 Extensions of Standard Map}
|
||||||
|
|
||||||
Provide useful functions and iterators on [Map.S]
|
Provide useful functions and iterators on [Map.S]
|
||||||
@since 0.5 *)
|
@since 0.5 *)
|
||||||
|
|
||||||
type 'a sequence = ('a -> unit) -> unit
|
type 'a sequence = ('a -> unit) -> unit
|
||||||
type 'a printer = Buffer.t -> 'a -> unit
|
type 'a printer = Buffer.t -> 'a -> unit
|
||||||
|
|
@ -66,13 +44,15 @@ module type S = sig
|
||||||
|
|
||||||
val to_list : 'a t -> (key * 'a) list
|
val to_list : 'a t -> (key * 'a) list
|
||||||
|
|
||||||
val pp : ?start:string -> ?stop:string -> ?arrow:string -> ?sep:string ->
|
val pp :
|
||||||
key printer -> 'a printer -> 'a t printer
|
?start:string -> ?stop:string -> ?arrow:string -> ?sep:string ->
|
||||||
|
key printer -> 'a printer -> 'a t printer
|
||||||
|
|
||||||
val print : ?start:string -> ?stop:string -> ?arrow:string -> ?sep:string ->
|
val print :
|
||||||
key formatter -> 'a formatter -> 'a t formatter
|
?start:string -> ?stop:string -> ?arrow:string -> ?sep:string ->
|
||||||
|
key formatter -> 'a formatter -> 'a t formatter
|
||||||
end
|
end
|
||||||
|
|
||||||
module Make(O : Map.OrderedType) : S
|
module Make(O : Map.OrderedType) : S
|
||||||
with type 'a t = 'a Map.Make(O).t
|
with type 'a t = 'a Map.Make(O).t
|
||||||
and type key = O.t
|
and type key = O.t
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,5 @@
|
||||||
(*
|
|
||||||
copyright (c) 2013-2014, simon cruanes
|
|
||||||
all rights reserved.
|
|
||||||
|
|
||||||
redistribution and use in source and binary forms, with or without
|
(* This file is free software, part of containers. See file "license" for more details. *)
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer. redistributions in binary
|
|
||||||
form must reproduce the above copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other materials provided with
|
|
||||||
the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*)
|
|
||||||
|
|
||||||
(** {1 Wrapper around Set} *)
|
(** {1 Wrapper around Set} *)
|
||||||
|
|
||||||
|
|
@ -46,11 +24,13 @@ module type S = sig
|
||||||
|
|
||||||
val to_list : t -> elt list
|
val to_list : t -> elt list
|
||||||
|
|
||||||
val pp : ?start:string -> ?stop:string -> ?sep:string ->
|
val pp :
|
||||||
elt printer -> t printer
|
?start:string -> ?stop:string -> ?sep:string ->
|
||||||
|
elt printer -> t printer
|
||||||
|
|
||||||
val print : ?start:string -> ?stop:string -> ?sep:string ->
|
val print :
|
||||||
elt formatter -> t formatter
|
?start:string -> ?stop:string -> ?sep:string ->
|
||||||
|
elt formatter -> t formatter
|
||||||
end
|
end
|
||||||
|
|
||||||
module Make(O : Map.OrderedType) = struct
|
module Make(O : Map.OrderedType) = struct
|
||||||
|
|
@ -76,9 +56,9 @@ module Make(O : Map.OrderedType) = struct
|
||||||
Buffer.add_string buf start;
|
Buffer.add_string buf start;
|
||||||
iter
|
iter
|
||||||
(fun x ->
|
(fun x ->
|
||||||
if !first then first := false else Buffer.add_string buf sep;
|
if !first then first := false else Buffer.add_string buf sep;
|
||||||
pp_x buf x;
|
pp_x buf x)
|
||||||
) m;
|
m;
|
||||||
Buffer.add_string buf stop
|
Buffer.add_string buf stop
|
||||||
|
|
||||||
let print ?(start="[") ?(stop="]") ?(sep=", ") pp_x fmt m =
|
let print ?(start="[") ?(stop="]") ?(sep=", ") pp_x fmt m =
|
||||||
|
|
@ -86,11 +66,12 @@ module Make(O : Map.OrderedType) = struct
|
||||||
let first = ref true in
|
let first = ref true in
|
||||||
iter
|
iter
|
||||||
(fun x ->
|
(fun x ->
|
||||||
if !first then first := false else (
|
if !first then first := false
|
||||||
Format.pp_print_string fmt sep;
|
else (
|
||||||
Format.pp_print_cut fmt ()
|
Format.pp_print_string fmt sep;
|
||||||
);
|
Format.pp_print_cut fmt ()
|
||||||
pp_x fmt x;
|
);
|
||||||
) m;
|
pp_x fmt x)
|
||||||
|
m;
|
||||||
Format.pp_print_string fmt stop
|
Format.pp_print_string fmt stop
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,9 @@
|
||||||
(*
|
|
||||||
copyright (c) 2013-2014, simon cruanes
|
|
||||||
all rights reserved.
|
|
||||||
|
|
||||||
redistribution and use in source and binary forms, with or without
|
(* This file is free software, part of containers. See file "license" for more details. *)
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer. redistributions in binary
|
|
||||||
form must reproduce the above copyright notice, this list of conditions and the
|
|
||||||
following disclaimer in the documentation and/or other materials provided with
|
|
||||||
the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*)
|
|
||||||
|
|
||||||
(** {1 Wrapper around Set}
|
(** {1 Wrapper around Set}
|
||||||
|
|
||||||
@since 0.9 *)
|
@since 0.9 *)
|
||||||
|
|
||||||
type 'a sequence = ('a -> unit) -> unit
|
type 'a sequence = ('a -> unit) -> unit
|
||||||
type 'a printer = Buffer.t -> 'a -> unit
|
type 'a printer = Buffer.t -> 'a -> unit
|
||||||
|
|
@ -48,13 +26,15 @@ module type S = sig
|
||||||
|
|
||||||
val to_list : t -> elt list
|
val to_list : t -> elt list
|
||||||
|
|
||||||
val pp : ?start:string -> ?stop:string -> ?sep:string ->
|
val pp :
|
||||||
elt printer -> t printer
|
?start:string -> ?stop:string -> ?sep:string ->
|
||||||
|
elt printer -> t printer
|
||||||
|
|
||||||
val print : ?start:string -> ?stop:string -> ?sep:string ->
|
val print :
|
||||||
elt formatter -> t formatter
|
?start:string -> ?stop:string -> ?sep:string ->
|
||||||
|
elt formatter -> t formatter
|
||||||
end
|
end
|
||||||
|
|
||||||
module Make(O : Set.OrderedType) : S
|
module Make(O : Set.OrderedType) : S
|
||||||
with type t = Set.Make(O).t
|
with type t = Set.Make(O).t
|
||||||
and type elt = O.t
|
and type elt = O.t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue