mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-09 20:55:31 -05:00
Merge branch 'master' into stable
This commit is contained in:
commit
9c80dba89e
12 changed files with 67 additions and 26 deletions
|
|
@ -16,3 +16,4 @@
|
||||||
- Johannes Kloos
|
- Johannes Kloos
|
||||||
- Geoff Gole (@gsg)
|
- Geoff Gole (@gsg)
|
||||||
- Roma Sokolov (@little-arhat)
|
- Roma Sokolov (@little-arhat)
|
||||||
|
- David Sheets (@dsheets)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,12 @@
|
||||||
= Changelog
|
= Changelog
|
||||||
|
|
||||||
|
== 0.22
|
||||||
|
|
||||||
|
- threads/CCLock: add `try_with_lock` to wrap `Mutex.try_lock`
|
||||||
|
- Add `CCMultiSet.remove_all`
|
||||||
|
- document errors in `CCIO` (close #86)
|
||||||
|
- use the new qtest/qcheck
|
||||||
|
|
||||||
== 0.21
|
== 0.21
|
||||||
|
|
||||||
- (breaking) make default `start`/`stop` arguments empty in printers (#82)
|
- (breaking) make default `start`/`stop` arguments empty in printers (#82)
|
||||||
|
|
|
||||||
|
|
@ -195,8 +195,6 @@ Iterators:
|
||||||
|
|
||||||
=== String
|
=== String
|
||||||
|
|
||||||
See http://cedeela.fr/~simon/software/containers/Containers_string[doc].
|
|
||||||
|
|
||||||
In the module `Containers_string`:
|
In the module `Containers_string`:
|
||||||
- `Levenshtein`: edition distance between two strings
|
- `Levenshtein`: edition distance between two strings
|
||||||
- `KMP`: Knuth-Morris-Pratt substring algorithm
|
- `KMP`: Knuth-Morris-Pratt substring algorithm
|
||||||
|
|
@ -204,8 +202,6 @@ In the module `Containers_string`:
|
||||||
|
|
||||||
=== Advanced
|
=== Advanced
|
||||||
|
|
||||||
See http://cedeela.fr/~simon/software/containers/Containers_advanced[doc].
|
|
||||||
|
|
||||||
In the module `Containers_advanced`:
|
In the module `Containers_advanced`:
|
||||||
- `CCLinq`, high-level query language over collections
|
- `CCLinq`, high-level query language over collections
|
||||||
- `CCCat`, a few categorical structures
|
- `CCCat`, a few categorical structures
|
||||||
|
|
|
||||||
2
_oasis
2
_oasis
|
|
@ -1,6 +1,6 @@
|
||||||
OASISFormat: 0.4
|
OASISFormat: 0.4
|
||||||
Name: containers
|
Name: containers
|
||||||
Version: 0.21
|
Version: 0.22
|
||||||
Homepage: https://github.com/c-cube/ocaml-containers
|
Homepage: https://github.com/c-cube/ocaml-containers
|
||||||
Authors: Simon Cruanes
|
Authors: Simon Cruanes
|
||||||
License: BSD-2-clause
|
License: BSD-2-clause
|
||||||
|
|
|
||||||
2
opam
2
opam
|
|
@ -40,8 +40,6 @@ depopts: [
|
||||||
]
|
]
|
||||||
conflicts: [
|
conflicts: [
|
||||||
"sequence" { < "0.5" }
|
"sequence" { < "0.5" }
|
||||||
"qtest" { < "2.2" }
|
|
||||||
"qcheck"
|
|
||||||
]
|
]
|
||||||
tags: [ "stdlib" "containers" "iterators" "list" "heap" "queue" ]
|
tags: [ "stdlib" "containers" "iterators" "list" "heap" "queue" ]
|
||||||
homepage: "https://github.com/c-cube/ocaml-containers/"
|
homepage: "https://github.com/c-cube/ocaml-containers/"
|
||||||
|
|
|
||||||
6
setup.ml
6
setup.ml
|
|
@ -1,7 +1,7 @@
|
||||||
(* setup.ml generated for the first time by OASIS v0.4.4 *)
|
(* setup.ml generated for the first time by OASIS v0.4.4 *)
|
||||||
|
|
||||||
(* OASIS_START *)
|
(* OASIS_START *)
|
||||||
(* DO NOT EDIT (digest: 5a4456e803f365ce3410624a599bc76f) *)
|
(* DO NOT EDIT (digest: 0f90f90895c33b40b6535d64f1d40619) *)
|
||||||
(*
|
(*
|
||||||
Regenerated by OASIS v0.4.7
|
Regenerated by OASIS v0.4.7
|
||||||
Visit http://oasis.forge.ocamlcore.org for more information and
|
Visit http://oasis.forge.ocamlcore.org for more information and
|
||||||
|
|
@ -7049,7 +7049,7 @@ let setup_t =
|
||||||
{
|
{
|
||||||
oasis_version = "0.4";
|
oasis_version = "0.4";
|
||||||
ocaml_version = Some (OASISVersion.VGreaterEqual "4.00.1");
|
ocaml_version = Some (OASISVersion.VGreaterEqual "4.00.1");
|
||||||
version = "0.21";
|
version = "0.22";
|
||||||
license =
|
license =
|
||||||
OASISLicense.DEP5License
|
OASISLicense.DEP5License
|
||||||
(OASISLicense.DEP5Unit
|
(OASISLicense.DEP5Unit
|
||||||
|
|
@ -9689,7 +9689,7 @@ let setup_t =
|
||||||
};
|
};
|
||||||
oasis_fn = Some "_oasis";
|
oasis_fn = Some "_oasis";
|
||||||
oasis_version = "0.4.7";
|
oasis_version = "0.4.7";
|
||||||
oasis_digest = Some "v\210\236\240,\180C\195X\143\011\\\217Y\180\206";
|
oasis_digest = Some "SzM\176?\172Sx\202\184\017a\207;\027f";
|
||||||
oasis_exec = None;
|
oasis_exec = None;
|
||||||
oasis_setup_args = [];
|
oasis_setup_args = [];
|
||||||
setup_update = false
|
setup_update = false
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ val with_in : ?mode:int -> ?flags:open_flag list ->
|
||||||
(** Open an input file with the given optional flag list, calls the function
|
(** Open an input file with the given optional flag list, calls the function
|
||||||
on the input channel. When the function raises or returns, the
|
on the input channel. When the function raises or returns, the
|
||||||
channel is closed.
|
channel is closed.
|
||||||
|
@raise Sys_error in case of error (same as {!open_in} and {!close_in})
|
||||||
@param flags opening flags (default [[Open_text]]). [Open_rdonly] is used in any cases *)
|
@param flags opening flags (default [[Open_text]]). [Open_rdonly] is used in any cases *)
|
||||||
|
|
||||||
val read_chunks : ?size:int -> in_channel -> string gen
|
val read_chunks : ?size:int -> in_channel -> string gen
|
||||||
|
|
@ -77,12 +78,14 @@ val with_out : ?mode:int -> ?flags:open_flag list ->
|
||||||
string -> (out_channel -> 'a) -> 'a
|
string -> (out_channel -> 'a) -> 'a
|
||||||
(** Same as {!with_in} but for an output channel
|
(** Same as {!with_in} but for an output channel
|
||||||
@param flags opening flags (default [[Open_creat; Open_trunc; Open_text]]).
|
@param flags opening flags (default [[Open_creat; Open_trunc; Open_text]]).
|
||||||
|
@raise Sys_error in case of error (same as {!open_out} and {!close_out})
|
||||||
[Open_wronly] is used in any cases *)
|
[Open_wronly] is used in any cases *)
|
||||||
|
|
||||||
val with_out_a : ?mode:int -> ?flags:open_flag list ->
|
val with_out_a : ?mode:int -> ?flags:open_flag list ->
|
||||||
string -> (out_channel -> 'a) -> 'a
|
string -> (out_channel -> 'a) -> 'a
|
||||||
(** Similar to {!with_out} but with the [[Open_append; Open_creat; Open_wronly]]
|
(** Similar to {!with_out} but with the [[Open_append; Open_creat; Open_wronly]]
|
||||||
flags activated, to append to the file *)
|
flags activated, to append to the file.
|
||||||
|
@raise Sys_error in case of error (same as {!open_out} and {!close_out}) *)
|
||||||
|
|
||||||
val write_line : out_channel -> string -> unit
|
val write_line : out_channel -> string -> unit
|
||||||
(** Write the given string on the channel, followed by "\n" *)
|
(** Write the given string on the channel, followed by "\n" *)
|
||||||
|
|
@ -102,6 +105,7 @@ val with_in_out : ?mode:int -> ?flags:open_flag list ->
|
||||||
string -> (in_channel -> out_channel -> 'a) -> 'a
|
string -> (in_channel -> out_channel -> 'a) -> 'a
|
||||||
(** Combines {!with_in} and {!with_out}.
|
(** Combines {!with_in} and {!with_out}.
|
||||||
@param flags opening flags (default [[Open_creat]])
|
@param flags opening flags (default [[Open_creat]])
|
||||||
|
@raise Sys_error in case of error
|
||||||
@since 0.12 *)
|
@since 0.12 *)
|
||||||
|
|
||||||
(** {2 Misc for Generators} *)
|
(** {2 Misc for Generators} *)
|
||||||
|
|
@ -145,7 +149,7 @@ module File : sig
|
||||||
(** [remove_exn path] tries to remove the file at [path] from the
|
(** [remove_exn path] tries to remove the file at [path] from the
|
||||||
file system.
|
file system.
|
||||||
|
|
||||||
{b Raises} [Sys_error] if there is no file at [path].
|
@raise Sys_error if there is no file at [path] or access rights are wrong.
|
||||||
@since 0.8 *)
|
@since 0.8 *)
|
||||||
|
|
||||||
val remove : t -> unit or_error
|
val remove : t -> unit or_error
|
||||||
|
|
@ -159,11 +163,13 @@ module File : sig
|
||||||
val read_dir : ?recurse:bool -> t -> t gen
|
val read_dir : ?recurse:bool -> t -> t gen
|
||||||
(** [read_dir d] returns a sequence of files and directory contained
|
(** [read_dir d] returns a sequence of files and directory contained
|
||||||
in the directory [d] (or an empty stream if [d] is not a directory)
|
in the directory [d] (or an empty stream if [d] is not a directory)
|
||||||
|
@raise Sys_error in case of error (e.g. permission denied)
|
||||||
@param recurse if true (default [false]), sub-directories are also
|
@param recurse if true (default [false]), sub-directories are also
|
||||||
explored *)
|
explored *)
|
||||||
|
|
||||||
val read_exn : t -> string
|
val read_exn : t -> string
|
||||||
(** Read the content of the given file, or raises some exception
|
(** Read the content of the given file, or raises some exception
|
||||||
|
@raise Sys_error in case of error
|
||||||
@since 0.16 *)
|
@since 0.16 *)
|
||||||
|
|
||||||
val read : t -> string or_error
|
val read : t -> string or_error
|
||||||
|
|
@ -172,6 +178,7 @@ module File : sig
|
||||||
|
|
||||||
val append_exn : t -> string -> unit
|
val append_exn : t -> string -> unit
|
||||||
(** Append the given string into the given file, possibly raising
|
(** Append the given string into the given file, possibly raising
|
||||||
|
@raise Sys_error in case of error
|
||||||
@since 0.16 *)
|
@since 0.16 *)
|
||||||
|
|
||||||
val append : t -> string -> unit or_error
|
val append : t -> string -> unit or_error
|
||||||
|
|
@ -180,6 +187,7 @@ module File : sig
|
||||||
|
|
||||||
val write_exn : t -> string -> unit
|
val write_exn : t -> string -> unit
|
||||||
(** Write the given string into the given file, possibly raising
|
(** Write the given string into the given file, possibly raising
|
||||||
|
@raise Sys_error in case of error
|
||||||
@since 0.16 *)
|
@since 0.16 *)
|
||||||
|
|
||||||
val write : t -> string -> unit or_error
|
val write : t -> string -> unit or_error
|
||||||
|
|
@ -192,7 +200,8 @@ module File : sig
|
||||||
(** Similar to {!read_dir} (with [recurse=true]), this function walks
|
(** Similar to {!read_dir} (with [recurse=true]), this function walks
|
||||||
a directory recursively and yields either files or directories.
|
a directory recursively and yields either files or directories.
|
||||||
Is a file anything that doesn't satisfy {!is_directory} (including
|
Is a file anything that doesn't satisfy {!is_directory} (including
|
||||||
symlinks, etc.) *)
|
symlinks, etc.)
|
||||||
|
@raise Sys_error in case of error (e.g. permission denied) during iteration *)
|
||||||
|
|
||||||
val show_walk_item : walk_item -> string
|
val show_walk_item : walk_item -> string
|
||||||
|
|
||||||
|
|
@ -204,5 +213,6 @@ module File : sig
|
||||||
After [f] returns, the file is deleted. Best to be used in
|
After [f] returns, the file is deleted. Best to be used in
|
||||||
combination with {!with_out}.
|
combination with {!with_out}.
|
||||||
See {!Filename.temp_file}
|
See {!Filename.temp_file}
|
||||||
|
@raise Sys_error in case of error
|
||||||
@since 0.17 *)
|
@since 0.17 *)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# OASIS_START
|
# OASIS_START
|
||||||
# DO NOT EDIT (digest: 2366633cbce20e67d6074e01f20927dc)
|
# DO NOT EDIT (digest: a16455ed7ae2b2e8c42add2f54bd446e)
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
requires = "bytes result"
|
requires = "bytes result"
|
||||||
archive(byte) = "containers.cma"
|
archive(byte) = "containers.cma"
|
||||||
|
|
@ -9,7 +9,7 @@ archive(native) = "containers.cmxa"
|
||||||
archive(native, plugin) = "containers.cmxs"
|
archive(native, plugin) = "containers.cmxs"
|
||||||
exists_if = "containers.cma"
|
exists_if = "containers.cma"
|
||||||
package "unix" (
|
package "unix" (
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
requires = "bytes unix"
|
requires = "bytes unix"
|
||||||
archive(byte) = "containers_unix.cma"
|
archive(byte) = "containers_unix.cma"
|
||||||
|
|
@ -20,7 +20,7 @@ package "unix" (
|
||||||
)
|
)
|
||||||
|
|
||||||
package "top" (
|
package "top" (
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
requires =
|
requires =
|
||||||
"compiler-libs.common containers containers.data containers.bigarray containers.string containers.unix containers.sexp containers.iter"
|
"compiler-libs.common containers containers.data containers.bigarray containers.string containers.unix containers.sexp containers.iter"
|
||||||
|
|
@ -32,7 +32,7 @@ package "top" (
|
||||||
)
|
)
|
||||||
|
|
||||||
package "thread" (
|
package "thread" (
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
requires = "containers threads"
|
requires = "containers threads"
|
||||||
archive(byte) = "containers_thread.cma"
|
archive(byte) = "containers_thread.cma"
|
||||||
|
|
@ -43,7 +43,7 @@ package "thread" (
|
||||||
)
|
)
|
||||||
|
|
||||||
package "string" (
|
package "string" (
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
requires = "bytes"
|
requires = "bytes"
|
||||||
archive(byte) = "containers_string.cma"
|
archive(byte) = "containers_string.cma"
|
||||||
|
|
@ -54,7 +54,7 @@ package "string" (
|
||||||
)
|
)
|
||||||
|
|
||||||
package "sexp" (
|
package "sexp" (
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
requires = "bytes"
|
requires = "bytes"
|
||||||
archive(byte) = "containers_sexp.cma"
|
archive(byte) = "containers_sexp.cma"
|
||||||
|
|
@ -65,7 +65,7 @@ package "sexp" (
|
||||||
)
|
)
|
||||||
|
|
||||||
package "iter" (
|
package "iter" (
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
archive(byte) = "containers_iter.cma"
|
archive(byte) = "containers_iter.cma"
|
||||||
archive(byte, plugin) = "containers_iter.cma"
|
archive(byte, plugin) = "containers_iter.cma"
|
||||||
|
|
@ -75,7 +75,7 @@ package "iter" (
|
||||||
)
|
)
|
||||||
|
|
||||||
package "io" (
|
package "io" (
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
requires = "bytes"
|
requires = "bytes"
|
||||||
archive(byte) = "containers_io.cma"
|
archive(byte) = "containers_io.cma"
|
||||||
|
|
@ -86,7 +86,7 @@ package "io" (
|
||||||
)
|
)
|
||||||
|
|
||||||
package "data" (
|
package "data" (
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
requires = "bytes"
|
requires = "bytes"
|
||||||
archive(byte) = "containers_data.cma"
|
archive(byte) = "containers_data.cma"
|
||||||
|
|
@ -97,7 +97,7 @@ package "data" (
|
||||||
)
|
)
|
||||||
|
|
||||||
package "bigarray" (
|
package "bigarray" (
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
requires = "containers bigarray bytes"
|
requires = "containers bigarray bytes"
|
||||||
archive(byte) = "containers_bigarray.cma"
|
archive(byte) = "containers_bigarray.cma"
|
||||||
|
|
@ -108,7 +108,7 @@ package "bigarray" (
|
||||||
)
|
)
|
||||||
|
|
||||||
package "advanced" (
|
package "advanced" (
|
||||||
version = "0.21"
|
version = "0.22"
|
||||||
description = "A modular standard library focused on data structures."
|
description = "A modular standard library focused on data structures."
|
||||||
requires = "containers sequence"
|
requires = "containers sequence"
|
||||||
archive(byte) = "containers_advanced.cma"
|
archive(byte) = "containers_advanced.cma"
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,10 @@ module type S = sig
|
||||||
@raise Invalid_argument if [n < 0]
|
@raise Invalid_argument if [n < 0]
|
||||||
@since 0.6 *)
|
@since 0.6 *)
|
||||||
|
|
||||||
|
val remove_all : t -> elt -> t
|
||||||
|
(** [remove_all set x] removes all occurrences of [x] from [set]
|
||||||
|
@since 0.22 *)
|
||||||
|
|
||||||
val update : t -> elt -> (int -> int) -> t
|
val update : t -> elt -> (int -> int) -> t
|
||||||
(** [update set x f] calls [f n] where [n] is the current multiplicity
|
(** [update set x f] calls [f n] where [n] is the current multiplicity
|
||||||
of [x] in [set] ([0] to indicate its absence); the result of [f n]
|
of [x] in [set] ([0] to indicate its absence); the result of [f n]
|
||||||
|
|
@ -136,6 +140,8 @@ module Make(O : Set.OrderedType) = struct
|
||||||
|
|
||||||
let remove ms x = remove_mult ms x 1
|
let remove ms x = remove_mult ms x 1
|
||||||
|
|
||||||
|
let remove_all ms x = M.remove x ms
|
||||||
|
|
||||||
let update ms x f =
|
let update ms x f =
|
||||||
let n = count ms x in
|
let n = count ms x in
|
||||||
match f n with
|
match f n with
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,10 @@ module type S = sig
|
||||||
@raise Invalid_argument if [n < 0]
|
@raise Invalid_argument if [n < 0]
|
||||||
@since 0.6 *)
|
@since 0.6 *)
|
||||||
|
|
||||||
|
val remove_all : t -> elt -> t
|
||||||
|
(** [remove_all set x] removes all occurrences of [x] from [set]
|
||||||
|
@since 0.22 *)
|
||||||
|
|
||||||
val update : t -> elt -> (int -> int) -> t
|
val update : t -> elt -> (int -> int) -> t
|
||||||
(** [update set x f] calls [f n] where [n] is the current multiplicity
|
(** [update set x f] calls [f n] where [n] is the current multiplicity
|
||||||
of [x] in [set] ([0] to indicate its absence); the result of [f n]
|
of [x] in [set] ([0] to indicate its absence); the result of [f n]
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,18 @@ let with_lock l f =
|
||||||
assert_equal 10 (get l)
|
assert_equal 10 (get l)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
let try_with_lock l f =
|
||||||
|
if Mutex.try_lock l.mutex
|
||||||
|
then
|
||||||
|
try
|
||||||
|
let x = f l.content in
|
||||||
|
Mutex.unlock l.mutex;
|
||||||
|
Some x
|
||||||
|
with e ->
|
||||||
|
Mutex.unlock l.mutex;
|
||||||
|
raise e
|
||||||
|
else None
|
||||||
|
|
||||||
module LockRef = struct
|
module LockRef = struct
|
||||||
type 'a t = 'a lock
|
type 'a t = 'a lock
|
||||||
let get t = t.content
|
let get t = t.content
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,12 @@ val with_lock : 'a t -> ('a -> 'b) -> 'b
|
||||||
the lock [l], in a critical section. If [f x] fails, [with_lock l f]
|
the lock [l], in a critical section. If [f x] fails, [with_lock l f]
|
||||||
fails too but the lock is released *)
|
fails too but the lock is released *)
|
||||||
|
|
||||||
|
val try_with_lock : 'a t -> ('a -> 'b) -> 'b option
|
||||||
|
(** [try_with_lock l f] runs [f x] in a critical section if [l] is not
|
||||||
|
locked. [x] is the value protected by the lock [l]. If [f x]
|
||||||
|
fails, [try_with_lock l f] fails too but the lock is released
|
||||||
|
@since 0.22 *)
|
||||||
|
|
||||||
(** Type allowing to manipulate the lock as a reference
|
(** Type allowing to manipulate the lock as a reference
|
||||||
@since 0.13 *)
|
@since 0.13 *)
|
||||||
module LockRef : sig
|
module LockRef : sig
|
||||||
|
|
@ -48,7 +54,8 @@ val mutex : _ t -> Mutex.t
|
||||||
(** Underlying mutex *)
|
(** Underlying mutex *)
|
||||||
|
|
||||||
val get : 'a t -> 'a
|
val get : 'a t -> 'a
|
||||||
(** Get the value in the lock. The value that is returned isn't protected! *)
|
(** Atomically get the value in the lock. The value that is returned
|
||||||
|
isn't protected! *)
|
||||||
|
|
||||||
val set : 'a t -> 'a -> unit
|
val set : 'a t -> 'a -> unit
|
||||||
(** Atomically set the value
|
(** Atomically set the value
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue