mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2026-01-28 03:44:51 -05:00
formattign, headers
This commit is contained in:
parent
b17f55b1d1
commit
0485bc5cd9
4 changed files with 150 additions and 238 deletions
|
|
@ -1,27 +1,5 @@
|
||||||
(*
|
|
||||||
Copyright (c) 2013, 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 Functional queues (fifo)} *)
|
(** {1 Functional queues (fifo)} *)
|
||||||
|
|
||||||
|
|
@ -87,7 +65,7 @@ let rec cons : 'a. 'a -> 'a t -> 'a t
|
||||||
(*$Q
|
(*$Q
|
||||||
(Q.pair Q.int (Q.list Q.int)) (fun (x,l) -> \
|
(Q.pair Q.int (Q.list Q.int)) (fun (x,l) -> \
|
||||||
cons x (of_list l) |> to_list = x::l)
|
cons x (of_list l) |> to_list = x::l)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let rec snoc : 'a. 'a t -> 'a -> 'a t
|
let rec snoc : 'a. 'a t -> 'a -> 'a t
|
||||||
= fun q x -> match q with
|
= fun q x -> match q with
|
||||||
|
|
@ -105,7 +83,7 @@ let rec snoc : 'a. 'a t -> 'a -> 'a t
|
||||||
(*$Q
|
(*$Q
|
||||||
(Q.pair Q.int (Q.list Q.int)) (fun (x,l) -> \
|
(Q.pair Q.int (Q.list Q.int)) (fun (x,l) -> \
|
||||||
snoc (of_list l) x |> to_list = l @ [x])
|
snoc (of_list l) x |> to_list = l @ [x])
|
||||||
*)
|
*)
|
||||||
|
|
||||||
(*$R
|
(*$R
|
||||||
let q = List.fold_left snoc empty [1;2;3;4;5] in
|
let q = List.fold_left snoc empty [1;2;3;4;5] in
|
||||||
|
|
@ -137,7 +115,7 @@ let rec take_front_exn : 'a. 'a t -> ('a *'a t)
|
||||||
(Q.pair Q.int (Q.list Q.int)) (fun (x,l) -> \
|
(Q.pair Q.int (Q.list Q.int)) (fun (x,l) -> \
|
||||||
let x', q = cons x (of_list l) |> take_front_exn in \
|
let x', q = cons x (of_list l) |> take_front_exn in \
|
||||||
x'=x && to_list q = l)
|
x'=x && to_list q = l)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
(*$R
|
(*$R
|
||||||
let q = of_list [1;2;3;4] in
|
let q = of_list [1;2;3;4] in
|
||||||
|
|
@ -198,7 +176,7 @@ let rec take_back_exn : 'a. 'a t -> 'a t * 'a
|
||||||
(Q.pair Q.int (Q.list Q.int)) (fun (x,l) -> \
|
(Q.pair Q.int (Q.list Q.int)) (fun (x,l) -> \
|
||||||
let q,x' = snoc (of_list l) x |> take_back_exn in \
|
let q,x' = snoc (of_list l) x |> take_back_exn in \
|
||||||
x'=x && to_list q = l)
|
x'=x && to_list q = l)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let take_back q =
|
let take_back q =
|
||||||
try Some (take_back_exn q)
|
try Some (take_back_exn q)
|
||||||
|
|
@ -326,7 +304,7 @@ let add_seq_front seq q =
|
||||||
(*$Q
|
(*$Q
|
||||||
Q.(pair (list int) (list int)) (fun (l1, l2) -> \
|
Q.(pair (list int) (list int)) (fun (l1, l2) -> \
|
||||||
add_seq_front (Sequence.of_list l1) (of_list l2) |> to_list = l1 @ l2)
|
add_seq_front (Sequence.of_list l1) (of_list l2) |> to_list = l1 @ l2)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let add_seq_back q seq =
|
let add_seq_back q seq =
|
||||||
let q = ref q in
|
let q = ref q in
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,5 @@
|
||||||
(*
|
|
||||||
Copyright (c) 2013, 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 Functional queues} *)
|
(** {1 Functional queues} *)
|
||||||
|
|
||||||
|
|
@ -33,7 +11,7 @@ type 'a printer = Format.formatter -> 'a -> unit
|
||||||
(** {2 Basics} *)
|
(** {2 Basics} *)
|
||||||
|
|
||||||
type +'a t
|
type +'a t
|
||||||
(** Queue containing elements of type 'a *)
|
(** Queue containing elements of type 'a *)
|
||||||
|
|
||||||
val empty : 'a t
|
val empty : 'a t
|
||||||
|
|
||||||
|
|
@ -107,7 +85,7 @@ val init : 'a t -> 'a t
|
||||||
(** {2 Global Operations} *)
|
(** {2 Global Operations} *)
|
||||||
|
|
||||||
val append : 'a t -> 'a t -> 'a t
|
val append : 'a t -> 'a t -> 'a t
|
||||||
(** Append two queues. Elements from the second one come
|
(** Append two queues. Elements from the second one come
|
||||||
after elements of the first one.
|
after elements of the first one.
|
||||||
Linear in the size of the second queue. *)
|
Linear in the size of the second queue. *)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,5 @@
|
||||||
(*
|
|
||||||
Copyright (c) 2013, 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 Continuation List} *)
|
(** {1 Continuation List} *)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,5 @@
|
||||||
(*
|
|
||||||
Copyright (c) 2013, 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 Continuation List} *)
|
(** {1 Continuation List} *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue