mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
break: rename fonction from *std_seq* to *seq*
This commit is contained in:
parent
8b41a2bf69
commit
8c3d716ab1
27 changed files with 230 additions and 188 deletions
|
|
@ -533,7 +533,7 @@ let to_string ?(sep=", ") item_to_string a =
|
||||||
(to_string string_of_int [|1|]) "1"
|
(to_string string_of_int [|1|]) "1"
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let to_std_seq a =
|
let to_seq a =
|
||||||
let rec aux i () =
|
let rec aux i () =
|
||||||
if i>= length a then Seq.Nil
|
if i>= length a then Seq.Nil
|
||||||
else Seq.Cons (a.(i), aux (i+1))
|
else Seq.Cons (a.(i), aux (i+1))
|
||||||
|
|
@ -541,9 +541,9 @@ let to_std_seq a =
|
||||||
aux 0
|
aux 0
|
||||||
|
|
||||||
(*$=
|
(*$=
|
||||||
[] (to_std_seq [||] |> CCList.of_std_seq)
|
[] (to_seq [||] |> CCList.of_seq)
|
||||||
[1;2;3] (to_std_seq [|1;2;3|] |> CCList.of_std_seq)
|
[1;2;3] (to_seq [|1;2;3|] |> CCList.of_seq)
|
||||||
CCList.(1 -- 1000) (to_std_seq (1--1000) |> CCList.of_std_seq)
|
CCList.(1 -- 1000) (to_seq (1--1000) |> CCList.of_seq)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let to_iter a k = iter k a
|
let to_iter a k = iter k a
|
||||||
|
|
|
||||||
|
|
@ -189,11 +189,12 @@ val to_iter : 'a t -> 'a iter
|
||||||
in modification of the iterator.
|
in modification of the iterator.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq : 'a t -> 'a Seq.t
|
val to_seq : 'a t -> 'a Seq.t
|
||||||
(** [to_std_seq a] returns a [Seq.t] of the elements of an array [a].
|
(** [to_seq a] returns a [Seq.t] of the elements of an array [a].
|
||||||
The input array [a] is shared with the sequence and modification of it will result
|
The input array [a] is shared with the sequence and modification of it will result
|
||||||
in modification of the sequence.
|
in modification of the sequence.
|
||||||
@since 2.8
|
Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val to_gen : 'a t -> 'a gen
|
val to_gen : 'a t -> 'a gen
|
||||||
|
|
|
||||||
|
|
@ -195,11 +195,12 @@ val to_iter : 'a t -> 'a iter
|
||||||
in modification of the iterator.
|
in modification of the iterator.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq : 'a t -> 'a Seq.t
|
val to_seq : 'a t -> 'a Seq.t
|
||||||
(** [to_std_seq a] returns a [Seq.t] of the elements of an array [a].
|
(** [to_seq a] returns a [Seq.t] of the elements of an array [a].
|
||||||
The input array [a] is shared with the sequence and modification of it will result
|
The input array [a] is shared with the sequence and modification of it will result
|
||||||
in modification of the sequence.
|
in modification of the sequence.
|
||||||
@since 2.8
|
Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val to_gen : 'a t -> 'a gen
|
val to_gen : 'a t -> 'a gen
|
||||||
|
|
|
||||||
|
|
@ -63,30 +63,30 @@ module Poly = struct
|
||||||
|
|
||||||
let add_iter tbl i = i (fun (k,v) -> Hashtbl.add tbl k v)
|
let add_iter tbl i = i (fun (k,v) -> Hashtbl.add tbl k v)
|
||||||
|
|
||||||
let add_std_seq tbl seq = Seq.iter (fun (k,v) -> Hashtbl.add tbl k v) seq
|
let add_seq tbl seq = Seq.iter (fun (k,v) -> Hashtbl.add tbl k v) seq
|
||||||
|
|
||||||
let of_iter i =
|
let of_iter i =
|
||||||
let tbl = Hashtbl.create 32 in
|
let tbl = Hashtbl.create 32 in
|
||||||
add_iter tbl i;
|
add_iter tbl i;
|
||||||
tbl
|
tbl
|
||||||
|
|
||||||
let of_std_seq i =
|
let of_seq i =
|
||||||
let tbl = Hashtbl.create 32 in
|
let tbl = Hashtbl.create 32 in
|
||||||
add_std_seq tbl i;
|
add_seq tbl i;
|
||||||
tbl
|
tbl
|
||||||
|
|
||||||
let add_iter_count tbl i = i (fun k -> incr tbl k)
|
let add_iter_count tbl i = i (fun k -> incr tbl k)
|
||||||
|
|
||||||
let add_std_seq_count tbl seq = Seq.iter (fun k -> incr tbl k) seq
|
let add_seq_count tbl seq = Seq.iter (fun k -> incr tbl k) seq
|
||||||
|
|
||||||
let of_iter_count i =
|
let of_iter_count i =
|
||||||
let tbl = Hashtbl.create 32 in
|
let tbl = Hashtbl.create 32 in
|
||||||
add_iter_count tbl i;
|
add_iter_count tbl i;
|
||||||
tbl
|
tbl
|
||||||
|
|
||||||
let of_std_seq_count i =
|
let of_seq_count i =
|
||||||
let tbl = Hashtbl.create 32 in
|
let tbl = Hashtbl.create 32 in
|
||||||
add_std_seq_count tbl i;
|
add_seq_count tbl i;
|
||||||
tbl
|
tbl
|
||||||
|
|
||||||
let to_list tbl =
|
let to_list tbl =
|
||||||
|
|
@ -210,7 +210,7 @@ module type S = sig
|
||||||
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val add_std_seq : 'a t -> (key * 'a) Seq.t -> unit
|
val add_seq : 'a t -> (key * 'a) Seq.t -> unit
|
||||||
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
|
|
@ -218,7 +218,7 @@ module type S = sig
|
||||||
(** From the given bindings, added in order.
|
(** From the given bindings, added in order.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq : (key * 'a) Seq.t -> 'a t
|
val of_seq : (key * 'a) Seq.t -> 'a t
|
||||||
(** From the given bindings, added in order.
|
(** From the given bindings, added in order.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
|
|
@ -228,7 +228,7 @@ module type S = sig
|
||||||
element of [i] occurs.
|
element of [i] occurs.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val add_std_seq_count : int t -> key Seq.t -> unit
|
val add_seq_count : int t -> key Seq.t -> unit
|
||||||
(** [add_seq_count tbl seq] increments the count of each element of [seq]
|
(** [add_seq_count tbl seq] increments the count of each element of [seq]
|
||||||
by calling {!incr}. This is useful for counting how many times each
|
by calling {!incr}. This is useful for counting how many times each
|
||||||
element of [seq] occurs.
|
element of [seq] occurs.
|
||||||
|
|
@ -238,7 +238,7 @@ module type S = sig
|
||||||
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq_count : key Seq.t -> int t
|
val of_seq_count : key Seq.t -> int t
|
||||||
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
|
|
@ -357,30 +357,30 @@ module Make(X : Hashtbl.HashedType)
|
||||||
|
|
||||||
let add_iter tbl i = i (fun (k,v) -> add tbl k v)
|
let add_iter tbl i = i (fun (k,v) -> add tbl k v)
|
||||||
|
|
||||||
let add_std_seq tbl seq = Seq.iter (fun (k,v) -> add tbl k v) seq
|
let add_seq tbl seq = Seq.iter (fun (k,v) -> add tbl k v) seq
|
||||||
|
|
||||||
let of_iter i =
|
let of_iter i =
|
||||||
let tbl = create 32 in
|
let tbl = create 32 in
|
||||||
add_iter tbl i;
|
add_iter tbl i;
|
||||||
tbl
|
tbl
|
||||||
|
|
||||||
let of_std_seq i =
|
let of_seq i =
|
||||||
let tbl = create 32 in
|
let tbl = create 32 in
|
||||||
add_std_seq tbl i;
|
add_seq tbl i;
|
||||||
tbl
|
tbl
|
||||||
|
|
||||||
let add_iter_count tbl i = i (fun k -> incr tbl k)
|
let add_iter_count tbl i = i (fun k -> incr tbl k)
|
||||||
|
|
||||||
let add_std_seq_count tbl seq = Seq.iter (fun k -> incr tbl k) seq
|
let add_seq_count tbl seq = Seq.iter (fun k -> incr tbl k) seq
|
||||||
|
|
||||||
let of_iter_count seq =
|
let of_iter_count seq =
|
||||||
let tbl = create 32 in
|
let tbl = create 32 in
|
||||||
add_iter_count tbl seq;
|
add_iter_count tbl seq;
|
||||||
tbl
|
tbl
|
||||||
|
|
||||||
let of_std_seq_count i =
|
let of_seq_count i =
|
||||||
let tbl = create 32 in
|
let tbl = create 32 in
|
||||||
add_std_seq_count tbl i;
|
add_seq_count tbl i;
|
||||||
tbl
|
tbl
|
||||||
|
|
||||||
let to_list tbl =
|
let to_list tbl =
|
||||||
|
|
|
||||||
|
|
@ -72,17 +72,19 @@ module Poly : sig
|
||||||
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val add_std_seq : ('a,'b) Hashtbl.t -> ('a * 'b) Seq.t -> unit
|
val add_seq : ('a,'b) Hashtbl.t -> ('a * 'b) Seq.t -> unit
|
||||||
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
||||||
@since 2.8 *)
|
Renamed from [add_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_iter : ('a * 'b) iter -> ('a,'b) Hashtbl.t
|
val of_iter : ('a * 'b) iter -> ('a,'b) Hashtbl.t
|
||||||
(** From the given bindings, added in order.
|
(** From the given bindings, added in order.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq : ('a * 'b) Seq.t -> ('a,'b) Hashtbl.t
|
val of_seq : ('a * 'b) Seq.t -> ('a,'b) Hashtbl.t
|
||||||
(** From the given bindings, added in order.
|
(** From the given bindings, added in order.
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val add_iter_count : ('a, int) Hashtbl.t -> 'a iter -> unit
|
val add_iter_count : ('a, int) Hashtbl.t -> 'a iter -> unit
|
||||||
(** [add_iter_count tbl i] increments the count of each element of [i]
|
(** [add_iter_count tbl i] increments the count of each element of [i]
|
||||||
|
|
@ -90,19 +92,21 @@ module Poly : sig
|
||||||
element of [i] occurs.
|
element of [i] occurs.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val add_std_seq_count : ('a, int) Hashtbl.t -> 'a Seq.t -> unit
|
val add_seq_count : ('a, int) Hashtbl.t -> 'a Seq.t -> unit
|
||||||
(** [add_seq_count tbl seq] increments the count of each element of [seq]
|
(** [add_seq_count tbl seq] increments the count of each element of [seq]
|
||||||
by calling {!incr}. This is useful for counting how many times each
|
by calling {!incr}. This is useful for counting how many times each
|
||||||
element of [seq] occurs.
|
element of [seq] occurs.
|
||||||
@since 2.8 *)
|
Renamed from [add_std_seq_count] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_iter_count : 'a iter -> ('a, int) Hashtbl.t
|
val of_iter_count : 'a iter -> ('a, int) Hashtbl.t
|
||||||
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq_count : 'a Seq.t -> ('a, int) Hashtbl.t
|
val of_seq_count : 'a Seq.t -> ('a, int) Hashtbl.t
|
||||||
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq_count] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val to_list : ('a,'b) Hashtbl.t -> ('a * 'b) list
|
val to_list : ('a,'b) Hashtbl.t -> ('a * 'b) list
|
||||||
(** [to_list tbl] returns the list of (key,value) bindings (order unspecified). *)
|
(** [to_list tbl] returns the list of (key,value) bindings (order unspecified). *)
|
||||||
|
|
@ -196,17 +200,19 @@ module type S = sig
|
||||||
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val add_std_seq : 'a t -> (key * 'a) Seq.t -> unit
|
val add_seq : 'a t -> (key * 'a) Seq.t -> unit
|
||||||
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
(** Add the corresponding pairs to the table, using {!Hashtbl.add}.
|
||||||
@since 2.8 *)
|
Renamed from [add_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_iter : (key * 'a) iter -> 'a t
|
val of_iter : (key * 'a) iter -> 'a t
|
||||||
(** From the given bindings, added in order.
|
(** From the given bindings, added in order.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq : (key * 'a) Seq.t -> 'a t
|
val of_seq : (key * 'a) Seq.t -> 'a t
|
||||||
(** From the given bindings, added in order.
|
(** From the given bindings, added in order.
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val add_iter_count : int t -> key iter -> unit
|
val add_iter_count : int t -> key iter -> unit
|
||||||
(** [add_iter_count tbl i] increments the count of each element of [i]
|
(** [add_iter_count tbl i] increments the count of each element of [i]
|
||||||
|
|
@ -214,19 +220,21 @@ module type S = sig
|
||||||
element of [i] occurs.
|
element of [i] occurs.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val add_std_seq_count : int t -> key Seq.t -> unit
|
val add_seq_count : int t -> key Seq.t -> unit
|
||||||
(** [add_seq_count tbl seq] increments the count of each element of [seq]
|
(** [add_seq_count tbl seq] increments the count of each element of [seq]
|
||||||
by calling {!incr}. This is useful for counting how many times each
|
by calling {!incr}. This is useful for counting how many times each
|
||||||
element of [seq] occurs.
|
element of [seq] occurs.
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq_count] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_iter_count : key iter -> int t
|
val of_iter_count : key iter -> int t
|
||||||
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq_count : key Seq.t -> int t
|
val of_seq_count : key Seq.t -> int t
|
||||||
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
(** Like {!add_seq_count}, but allocates a new table and returns it.
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq_count] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val to_list : 'a t -> (key * 'a) list
|
val to_list : 'a t -> (key * 'a) list
|
||||||
(** [to_list tbl] returns the list of (key,value) bindings (order unspecified). *)
|
(** [to_list tbl] returns the list of (key,value) bindings (order unspecified). *)
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ module type S = sig
|
||||||
(** Like {!add_list}.
|
(** Like {!add_list}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val add_std_seq : t -> elt Seq.t -> t
|
val add_seq : t -> elt Seq.t -> t
|
||||||
(** Like {!add_list}.
|
(** Like {!add_list}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
|
|
@ -183,7 +183,7 @@ module type S = sig
|
||||||
(** Build a heap from a given [iter]. Complexity: [O(n log n)].
|
(** Build a heap from a given [iter]. Complexity: [O(n log n)].
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq : elt Seq.t -> t
|
val of_seq : elt Seq.t -> t
|
||||||
(** Build a heap from a given [Seq.t]. Complexity: [O(n log n)].
|
(** Build a heap from a given [Seq.t]. Complexity: [O(n log n)].
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ module type S = sig
|
||||||
(** Return a [iter] of the elements of the heap.
|
(** Return a [iter] of the elements of the heap.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq : t -> elt Seq.t
|
val to_seq : t -> elt Seq.t
|
||||||
(** Return a [Seq.t] of the elements of the heap.
|
(** Return a [Seq.t] of the elements of the heap.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
|
|
@ -199,7 +199,7 @@ module type S = sig
|
||||||
(** Iterate on the elements, in increasing order.
|
(** Iterate on the elements, in increasing order.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq_sorted : t -> elt Seq.t
|
val to_seq_sorted : t -> elt Seq.t
|
||||||
(** Iterate on the elements, in increasing order.
|
(** Iterate on the elements, in increasing order.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
|
|
@ -366,17 +366,17 @@ module Make(E : PARTIAL_ORD) : S with type elt = E.t = struct
|
||||||
i (fun x -> h := insert x !h);
|
i (fun x -> h := insert x !h);
|
||||||
!h
|
!h
|
||||||
|
|
||||||
let add_std_seq h seq =
|
let add_seq h seq =
|
||||||
let h = ref h in
|
let h = ref h in
|
||||||
Seq.iter (fun x -> h := insert x !h) seq;
|
Seq.iter (fun x -> h := insert x !h) seq;
|
||||||
!h
|
!h
|
||||||
|
|
||||||
let of_iter i = add_iter empty i
|
let of_iter i = add_iter empty i
|
||||||
let of_std_seq seq = add_std_seq empty seq
|
let of_seq seq = add_seq empty seq
|
||||||
|
|
||||||
let to_iter h k = iter k h
|
let to_iter h k = iter k h
|
||||||
|
|
||||||
let to_std_seq h =
|
let to_seq h =
|
||||||
(* use an explicit stack [st] *)
|
(* use an explicit stack [st] *)
|
||||||
let rec aux st () =
|
let rec aux st () =
|
||||||
match st with
|
match st with
|
||||||
|
|
@ -392,9 +392,9 @@ module Make(E : PARTIAL_ORD) : S with type elt = E.t = struct
|
||||||
in
|
in
|
||||||
fun k -> recurse heap k
|
fun k -> recurse heap k
|
||||||
|
|
||||||
let rec to_std_seq_sorted h () = match take h with
|
let rec to_seq_sorted h () = match take h with
|
||||||
| None -> Seq.Nil
|
| None -> Seq.Nil
|
||||||
| Some (h', x) -> Seq.Cons (x, to_std_seq_sorted h')
|
| Some (h', x) -> Seq.Cons (x, to_seq_sorted h')
|
||||||
|
|
||||||
let rec add_klist h l = match l() with
|
let rec add_klist h l = match l() with
|
||||||
| `Nil -> h
|
| `Nil -> h
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,7 @@ module type S = sig
|
||||||
val size : t -> int
|
val size : t -> int
|
||||||
(** [size h] is the number of elements in the heap [h]. Linear complexity. *)
|
(** [size h] is the number of elements in the heap [h]. Linear complexity. *)
|
||||||
|
|
||||||
(** {2 Conversions}
|
(** {2 Conversions} *)
|
||||||
|
|
||||||
The interface of [of_gen], [of_seq], [of_klist]
|
|
||||||
has changed since 0.16 (the old signatures
|
|
||||||
are now [add_seq], [add_gen], [add_klist]). *)
|
|
||||||
|
|
||||||
val to_list : t -> elt list
|
val to_list : t -> elt list
|
||||||
(** [to_list h] returns the elements of the heap [h], in no particular order. *)
|
(** [to_list h] returns the elements of the heap [h], in no particular order. *)
|
||||||
|
|
@ -116,35 +112,39 @@ module type S = sig
|
||||||
(** [add_iter h iter] is like {!add_list}.
|
(** [add_iter h iter] is like {!add_list}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val add_std_seq : t -> elt Seq.t -> t
|
val add_seq : t -> elt Seq.t -> t
|
||||||
(** [add_std_seq h seq] is like {!add_list}.
|
(** [add_seq h seq] is like {!add_list}.
|
||||||
@since 2.8 *)
|
Renamed from [add_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_iter : elt iter -> t
|
val of_iter : elt iter -> t
|
||||||
(** [of_iter iter] builds a heap from a given [iter]. Complexity: [O(n log n)].
|
(** [of_iter iter] builds a heap from a given [iter]. Complexity: [O(n log n)].
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq : elt Seq.t -> t
|
val of_seq : elt Seq.t -> t
|
||||||
(** [of_std_seq seq] builds a heap from a given [Seq.t]. Complexity: [O(n log n)].
|
(** [of_seq seq] builds a heap from a given [Seq.t]. Complexity: [O(n log n)].
|
||||||
@since 2.8 *)
|
Renamed from [of_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val to_iter : t -> elt iter
|
val to_iter : t -> elt iter
|
||||||
(** [to_iter h] returns a [iter] of the elements of the heap [h].
|
(** [to_iter h] returns a [iter] of the elements of the heap [h].
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq : t -> elt Seq.t
|
val to_seq : t -> elt Seq.t
|
||||||
(** [to_std_seq h] returns a [Seq.t] of the elements of the heap [h].
|
(** [to_seq h] returns a [Seq.t] of the elements of the heap [h].
|
||||||
@since 2.8 *)
|
Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val to_iter_sorted : t -> elt iter
|
val to_iter_sorted : t -> elt iter
|
||||||
(** [to_iter_sorted h] returns a [iter] by iterating on the elements of [h],
|
(** [to_iter_sorted h] returns a [iter] by iterating on the elements of [h],
|
||||||
in increasing order.
|
in increasing order.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq_sorted : t -> elt Seq.t
|
val to_seq_sorted : t -> elt Seq.t
|
||||||
(** [to_std_seq_sorted h] returns a [Seq.t] by iterating on the elements of [h],
|
(** [to_seq_sorted h] returns a [Seq.t] by iterating on the elements of [h],
|
||||||
in increasing order.
|
in increasing order.
|
||||||
@since 2.8 *)
|
Renamed from [to_std_seq_sorted] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val add_klist : t -> elt klist -> t
|
val add_klist : t -> elt klist -> t
|
||||||
(** [add_klist h klist] adds the klist [klist] to the heap [h].
|
(** [add_klist h klist] adds the klist [klist] to the heap [h].
|
||||||
|
|
|
||||||
|
|
@ -1715,25 +1715,25 @@ let to_string ?(start="") ?(stop="") ?(sep=", ") item_to_string l =
|
||||||
|
|
||||||
let to_iter l k = List.iter k l
|
let to_iter l k = List.iter k l
|
||||||
|
|
||||||
let rec to_std_seq l () = match l with
|
let rec to_seq l () = match l with
|
||||||
| [] -> Seq.Nil
|
| [] -> Seq.Nil
|
||||||
| x :: tl -> Seq.Cons (x, to_std_seq tl)
|
| x :: tl -> Seq.Cons (x, to_seq tl)
|
||||||
|
|
||||||
let of_iter i =
|
let of_iter i =
|
||||||
let l = ref [] in
|
let l = ref [] in
|
||||||
i (fun x -> l := x :: !l);
|
i (fun x -> l := x :: !l);
|
||||||
List.rev !l
|
List.rev !l
|
||||||
|
|
||||||
let of_std_seq_rev l =
|
let of_seq_rev l =
|
||||||
let rec loop acc s = match s() with
|
let rec loop acc s = match s() with
|
||||||
| Seq.Nil -> acc
|
| Seq.Nil -> acc
|
||||||
| Seq.Cons (x,tl) -> loop (x::acc) tl
|
| Seq.Cons (x,tl) -> loop (x::acc) tl
|
||||||
in
|
in
|
||||||
loop [] l
|
loop [] l
|
||||||
|
|
||||||
let of_std_seq l =
|
let of_seq l =
|
||||||
let rec direct i seq =
|
let rec direct i seq =
|
||||||
if i <= 0 then List.rev (of_std_seq_rev seq)
|
if i <= 0 then List.rev (of_seq_rev seq)
|
||||||
else (
|
else (
|
||||||
match seq() with
|
match seq() with
|
||||||
| Seq.Nil -> []
|
| Seq.Nil -> []
|
||||||
|
|
|
||||||
|
|
@ -754,23 +754,26 @@ val to_iter : 'a t -> 'a iter
|
||||||
(** [to_iter l] returns a [iter] of the elements of the list [l].
|
(** [to_iter l] returns a [iter] of the elements of the list [l].
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq : 'a t -> 'a Seq.t
|
val to_seq : 'a t -> 'a Seq.t
|
||||||
(** [to_std_seq l] returns a [Seq.t] of the elements of the list [l].
|
(** [to_seq l] returns a [Seq.t] of the elements of the list [l].
|
||||||
@since 2.8 *)
|
Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_iter : 'a iter -> 'a t
|
val of_iter : 'a iter -> 'a t
|
||||||
(** [of_iter iter] builds a list from a given [iter].
|
(** [of_iter iter] builds a list from a given [iter].
|
||||||
In the result, elements appear in the same order as they did in the source [iter].
|
In the result, elements appear in the same order as they did in the source [iter].
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq_rev : 'a Seq.t -> 'a t
|
val of_seq_rev : 'a Seq.t -> 'a t
|
||||||
(** [of_std_seq_rev seq] builds a list from a given [Seq.t], in reverse order.
|
(** [of_seq_rev seq] builds a list from a given [Seq.t], in reverse order.
|
||||||
@since 2.8 *)
|
Renamed from [to_std_seq_rev] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_std_seq : 'a Seq.t -> 'a t
|
val of_seq : 'a Seq.t -> 'a t
|
||||||
(** [of_std_seq seq] builds a list from a given [Seq.t].
|
(** [of_seq seq] builds a list from a given [Seq.t].
|
||||||
In the result, elements appear in the same order as they did in the source [Seq.t].
|
In the result, elements appear in the same order as they did in the source [Seq.t].
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val to_gen : 'a t -> 'a gen
|
val to_gen : 'a t -> 'a gen
|
||||||
(** [to_gen l] returns a [gen] of the elements of the list [l]. *)
|
(** [to_gen l] returns a [gen] of the elements of the list [l]. *)
|
||||||
|
|
|
||||||
|
|
@ -758,23 +758,26 @@ val to_iter : 'a t -> 'a iter
|
||||||
(** [to_iter l] returns a [iter] of the elements of the list [l].
|
(** [to_iter l] returns a [iter] of the elements of the list [l].
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq : 'a t -> 'a Seq.t
|
val to_seq : 'a t -> 'a Seq.t
|
||||||
(** [to_std_seq l] returns a [Seq.t] of the elements of the list [l].
|
(** [to_seq l] returns a [Seq.t] of the elements of the list [l].
|
||||||
@since 2.8 *)
|
Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_iter : 'a iter -> 'a t
|
val of_iter : 'a iter -> 'a t
|
||||||
(** [of_iter iter] builds a list from a given [iter].
|
(** [of_iter iter] builds a list from a given [iter].
|
||||||
In the result, elements appear in the same order as they did in the source [iter].
|
In the result, elements appear in the same order as they did in the source [iter].
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq_rev : 'a Seq.t -> 'a t
|
val of_seq_rev : 'a Seq.t -> 'a t
|
||||||
(** [of_std_seq_rev seq] builds a list from a given [Seq.t], in reverse order.
|
(** [of_seq_rev seq] builds a list from a given [Seq.t], in reverse order.
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq_rev] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_std_seq : 'a Seq.t -> 'a t
|
val of_seq : 'a Seq.t -> 'a t
|
||||||
(** [of_std_seq seq] builds a list from a given [Seq.t].
|
(** [of_seq seq] builds a list from a given [Seq.t].
|
||||||
In the result, elements appear in the same order as they did in the source [Seq.t].
|
In the result, elements appear in the same order as they did in the source [Seq.t].
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val to_gen : 'a t -> 'a gen
|
val to_gen : 'a t -> 'a gen
|
||||||
(** [to_gen l] returns a [gen] of the elements of the list [l]. *)
|
(** [to_gen l] returns a [gen] of the elements of the list [l]. *)
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,11 @@ module type S = sig
|
||||||
(** Like {!of_list}.
|
(** Like {!of_list}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val add_std_seq : 'a t -> (key * 'a) Seq.t -> 'a t
|
val add_seq : 'a t -> (key * 'a) Seq.t -> 'a t
|
||||||
(** Like {!add_list}.
|
(** Like {!add_list}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq : (key * 'a) Seq.t -> 'a t
|
val of_seq : (key * 'a) Seq.t -> 'a t
|
||||||
(** Like {!of_list}.
|
(** Like {!of_list}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
|
|
@ -193,12 +193,12 @@ module Make(O : Map.OrderedType) = struct
|
||||||
| Some v1, Some v2 -> f k (`Both (v1,v2)))
|
| Some v1, Some v2 -> f k (`Both (v1,v2)))
|
||||||
a b
|
a b
|
||||||
|
|
||||||
let add_std_seq m s =
|
let add_seq m s =
|
||||||
let m = ref m in
|
let m = ref m in
|
||||||
Seq.iter (fun (k,v) -> m := add k v !m) s;
|
Seq.iter (fun (k,v) -> m := add k v !m) s;
|
||||||
!m
|
!m
|
||||||
|
|
||||||
let of_std_seq s = add_std_seq empty s
|
let of_seq s = add_seq empty s
|
||||||
|
|
||||||
let add_iter m s =
|
let add_iter m s =
|
||||||
let m = ref m in
|
let m = ref m in
|
||||||
|
|
|
||||||
|
|
@ -80,15 +80,17 @@ module type S = sig
|
||||||
Like {!of_list}.
|
Like {!of_list}.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val add_std_seq : 'a t -> (key * 'a) Seq.t -> 'a t
|
val add_seq : 'a t -> (key * 'a) Seq.t -> 'a t
|
||||||
(** [add_std_seq m seq] adds the given [Seq.t] of bindings to the map [m].
|
(** [add_seq m seq] adds the given [Seq.t] of bindings to the map [m].
|
||||||
Like {!add_list}.
|
Like {!add_list}.
|
||||||
@since 2.8 *)
|
Renamed from [add_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_std_seq : (key * 'a) Seq.t -> 'a t
|
val of_seq : (key * 'a) Seq.t -> 'a t
|
||||||
(** [of_std_seq seq] builds a map from the given [Seq.t] of bindings.
|
(** [of_seq seq] builds a map from the given [Seq.t] of bindings.
|
||||||
Like {!of_list}.
|
Like {!of_list}.
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val add_iter : 'a t -> (key * 'a) iter -> 'a t
|
val add_iter : 'a t -> (key * 'a) iter -> 'a t
|
||||||
(** [add_iter m iter] adds the given [iter] of bindings to the map [m].
|
(** [add_iter m iter] adds the given [iter] of bindings to the map [m].
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ let to_iter o k = match o with
|
||||||
|
|
||||||
let to_seq = to_iter
|
let to_seq = to_iter
|
||||||
|
|
||||||
let to_std_seq o () = match o with
|
let to_seq o () = match o with
|
||||||
| None -> Seq.Nil
|
| None -> Seq.Nil
|
||||||
| Some x -> Seq.Cons (x, Seq.empty)
|
| Some x -> Seq.Cons (x, Seq.empty)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -218,11 +218,12 @@ val to_gen : 'a t -> 'a gen
|
||||||
(** [to_gen o] is [o] as a [gen]. [Some x] is the singleton [gen] containing [x]
|
(** [to_gen o] is [o] as a [gen]. [Some x] is the singleton [gen] containing [x]
|
||||||
and [None] is the empty [gen]. *)
|
and [None] is the empty [gen]. *)
|
||||||
|
|
||||||
val to_std_seq : 'a t -> 'a Seq.t
|
val to_seq : 'a t -> 'a Seq.t
|
||||||
(** [to_std_seq o] is [o] as a sequence [Seq.t]. [Some x] is the singleton sequence containing [x]
|
(** [to_seq o] is [o] as a sequence [Seq.t]. [Some x] is the singleton sequence containing [x]
|
||||||
and [None] is the empty sequence.
|
and [None] is the empty sequence.
|
||||||
Same as {!Stdlib.Option.to_seq}
|
Same as {!Stdlib.Option.to_seq}
|
||||||
@since 2.8 *)
|
Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val to_iter : 'a t -> 'a iter
|
val to_iter : 'a t -> 'a iter
|
||||||
(** [to_iter o] returns an internal iterator, like in the library [Iter].
|
(** [to_iter o] returns an internal iterator, like in the library [Iter].
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,7 @@ let of_opt = function
|
||||||
| None -> Error "of_opt"
|
| None -> Error "of_opt"
|
||||||
| Some x -> Ok x
|
| Some x -> Ok x
|
||||||
|
|
||||||
let to_std_seq e () = match e with
|
let to_seq e () = match e with
|
||||||
| Ok x -> Seq.Cons (x, Seq.empty)
|
| Ok x -> Seq.Cons (x, Seq.empty)
|
||||||
| Error _ -> Seq.Nil
|
| Error _ -> Seq.Nil
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,8 +262,9 @@ val of_opt : 'a option -> ('a, string) t
|
||||||
val to_iter : ('a, _) t -> 'a iter
|
val to_iter : ('a, _) t -> 'a iter
|
||||||
(** @since 2.8 *)
|
(** @since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq : ('a, _) t -> 'a Seq.t
|
val to_seq : ('a, _) t -> 'a Seq.t
|
||||||
(** @since 2.8 *)
|
(** Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
type ('a, 'b) error = [`Ok of 'a | `Error of 'b]
|
type ('a, 'b) error = [`Ok of 'a | `Error of 'b]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,17 @@ module type S = sig
|
||||||
(** Build a set from the given [iter] of elements.
|
(** Build a set from the given [iter] of elements.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
|
val of_seq : elt Seq.t -> t
|
||||||
|
(** Build a set from the given [seq] of elements.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val add_iter : t -> elt iter -> t
|
val add_iter : t -> elt iter -> t
|
||||||
(** @since 2.8 *)
|
(** @since 2.8 *)
|
||||||
|
|
||||||
|
val add_seq : elt Seq.t -> t -> t
|
||||||
|
(** @since NEXT_RELEASE *)
|
||||||
|
|
||||||
|
|
||||||
val to_iter : t -> elt iter
|
val to_iter : t -> elt iter
|
||||||
(** [to_iter t] converts the set [t] to a [iter] of the elements.
|
(** [to_iter t] converts the set [t] to a [iter] of the elements.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
@ -135,12 +143,12 @@ module Make(O : Map.OrderedType) = struct
|
||||||
|
|
||||||
include S
|
include S
|
||||||
|
|
||||||
let add_std_seq set seq =
|
let add_seq seq set =
|
||||||
let set = ref set in
|
let set = ref set in
|
||||||
Seq.iter (fun x -> set := add x !set) seq;
|
Seq.iter (fun x -> set := add x !set) seq;
|
||||||
!set
|
!set
|
||||||
|
|
||||||
let of_std_seq s = add_std_seq empty s
|
let of_seq s = add_seq s empty
|
||||||
|
|
||||||
let add_iter set i =
|
let add_iter set i =
|
||||||
let set = ref set in
|
let set = ref set in
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,16 @@ module type S = sig
|
||||||
(** Build a set from the given [iter] of elements.
|
(** Build a set from the given [iter] of elements.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
|
val of_seq : elt Seq.t -> t
|
||||||
|
(** Build a set from the given [seq] of elements.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val add_iter : t -> elt iter -> t
|
val add_iter : t -> elt iter -> t
|
||||||
(** @since 2.8 *)
|
(** @since 2.8 *)
|
||||||
|
|
||||||
|
val add_seq : elt Seq.t -> t -> t
|
||||||
|
(** @since NEXT_RELEASE *)
|
||||||
|
|
||||||
val to_iter : t -> elt iter
|
val to_iter : t -> elt iter
|
||||||
(** [to_iter t] converts the set [t] to a [iter] of the elements.
|
(** [to_iter t] converts the set [t] to a [iter] of the elements.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
|
||||||
|
|
@ -416,9 +416,9 @@ module Split = struct
|
||||||
Seq.Cons (k s i len , make state')
|
Seq.Cons (k s i len , make state')
|
||||||
in make (SplitAt 0)
|
in make (SplitAt 0)
|
||||||
|
|
||||||
let std_seq ?(drop=default_drop) ~by s = _mkseq ~drop ~by s _tuple3
|
let seq ?(drop=default_drop) ~by s = _mkseq ~drop ~by s _tuple3
|
||||||
|
|
||||||
let std_seq_cpy ?(drop=default_drop) ~by s = _mkseq ~drop ~by s String.sub
|
let seq_cpy ?(drop=default_drop) ~by s = _mkseq ~drop ~by s String.sub
|
||||||
|
|
||||||
let _mkklist ~drop ~by s k =
|
let _mkklist ~drop ~by s k =
|
||||||
let by = Find.compile by in
|
let by = Find.compile by in
|
||||||
|
|
@ -446,9 +446,6 @@ module Split = struct
|
||||||
let iter ?(drop=default_drop) ~by s = _mk_iter ~drop ~by s _tuple3
|
let iter ?(drop=default_drop) ~by s = _mk_iter ~drop ~by s _tuple3
|
||||||
let iter_cpy ?(drop=default_drop) ~by s = _mk_iter ~drop ~by s String.sub
|
let iter_cpy ?(drop=default_drop) ~by s = _mk_iter ~drop ~by s String.sub
|
||||||
|
|
||||||
let seq = iter
|
|
||||||
let seq_cpy = iter_cpy
|
|
||||||
|
|
||||||
let left_exn ~by s =
|
let left_exn ~by s =
|
||||||
let i = find ~sub:by s in
|
let i = find ~sub:by s in
|
||||||
if i = ~-1 then raise Not_found
|
if i = ~-1 then raise Not_found
|
||||||
|
|
@ -815,18 +812,18 @@ let of_gen g =
|
||||||
|
|
||||||
let to_iter s k = String.iter k s
|
let to_iter s k = String.iter k s
|
||||||
|
|
||||||
let rec _to_std_seq s i len () =
|
let rec _to_seq s i len () =
|
||||||
if len=0 then Seq.Nil
|
if len=0 then Seq.Nil
|
||||||
else Seq.Cons (s.[i], _to_std_seq s (i+1)(len-1))
|
else Seq.Cons (s.[i], _to_seq s (i+1)(len-1))
|
||||||
|
|
||||||
let to_std_seq s = _to_std_seq s 0 (String.length s)
|
let to_seq s = _to_seq s 0 (String.length s)
|
||||||
|
|
||||||
let of_iter i =
|
let of_iter i =
|
||||||
let b = Buffer.create 32 in
|
let b = Buffer.create 32 in
|
||||||
i (Buffer.add_char b);
|
i (Buffer.add_char b);
|
||||||
Buffer.contents b
|
Buffer.contents b
|
||||||
|
|
||||||
let of_std_seq seq =
|
let of_seq seq =
|
||||||
let b = Buffer.create 32 in
|
let b = Buffer.create 32 in
|
||||||
Seq.iter (Buffer.add_char b) seq;
|
Seq.iter (Buffer.add_char b) seq;
|
||||||
Buffer.contents b
|
Buffer.contents b
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,10 @@ val to_iter : t -> char iter
|
||||||
(** Return the [iter] of characters contained in the string.
|
(** Return the [iter] of characters contained in the string.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq : t -> char Seq.t
|
val to_seq : t -> char Seq.t
|
||||||
(** [to_std_seq s] returns a [Seq.t] of the bytes in [s].
|
(** [to_seq s] returns a [Seq.t] of the bytes in [s].
|
||||||
@since 2.8
|
Renamed from [to std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val to_list : t -> char list
|
val to_list : t -> char list
|
||||||
|
|
@ -90,9 +91,10 @@ val of_iter : char iter -> string
|
||||||
(** Convert a [iter] of characters to a string.
|
(** Convert a [iter] of characters to a string.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq : char Seq.t -> string
|
val of_seq : char Seq.t -> string
|
||||||
(** Convert a [sequence] of characters to a string.
|
(** Convert a [sequence] of characters to a string.
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_list : char list -> string
|
val of_list : char list -> string
|
||||||
(** Convert a list of characters to a string. *)
|
(** Convert a list of characters to a string. *)
|
||||||
|
|
@ -346,8 +348,9 @@ module Split : sig
|
||||||
val iter : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) iter
|
val iter : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) iter
|
||||||
(** @since 2.8 *)
|
(** @since 2.8 *)
|
||||||
|
|
||||||
val std_seq : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) Seq.t
|
val seq : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) Seq.t
|
||||||
(** @since 2.8 *)
|
(** Renamed from [std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
(** {4 Copying functions}
|
(** {4 Copying functions}
|
||||||
|
|
||||||
|
|
@ -361,8 +364,9 @@ module Split : sig
|
||||||
val iter_cpy : ?drop:drop_if_empty -> by:string -> string -> string iter
|
val iter_cpy : ?drop:drop_if_empty -> by:string -> string -> string iter
|
||||||
(** @since 2.8 *)
|
(** @since 2.8 *)
|
||||||
|
|
||||||
val std_seq_cpy : ?drop:drop_if_empty -> by:string -> string -> string Seq.t
|
val seq_cpy : ?drop:drop_if_empty -> by:string -> string -> string Seq.t
|
||||||
(** @since 2.8 *)
|
(** Renamed from [std_seq_cpy] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val left : by:string -> string -> (string * string) option
|
val left : by:string -> string -> (string * string) option
|
||||||
(** Split on the first occurrence of [by] from the leftmost part of
|
(** Split on the first occurrence of [by] from the leftmost part of
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,10 @@ val to_iter : t -> char iter
|
||||||
(** Return the [iter] of characters contained in the string.
|
(** Return the [iter] of characters contained in the string.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq : t -> char Seq.t
|
val to_seq : t -> char Seq.t
|
||||||
(** [to_std_seq s] returns a [Seq.t] of the bytes in [s].
|
(** [to_seq s] returns a [Seq.t] of the bytes in [s].
|
||||||
@since 2.8
|
Renamed from [to std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val to_list : t -> char list
|
val to_list : t -> char list
|
||||||
|
|
@ -93,9 +94,10 @@ val of_iter : char iter -> string
|
||||||
(** Convert a [iter] of characters to a string.
|
(** Convert a [iter] of characters to a string.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val of_std_seq : char Seq.t -> string
|
val of_seq : char Seq.t -> string
|
||||||
(** Convert a [sequence] of characters to a string.
|
(** Convert a [sequence] of characters to a string.
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_list : char list -> string
|
val of_list : char list -> string
|
||||||
(** Convert a list of characters to a string. *)
|
(** Convert a list of characters to a string. *)
|
||||||
|
|
@ -365,8 +367,9 @@ module Split : sig
|
||||||
val iter : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) iter
|
val iter : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) iter
|
||||||
(** @since 2.8 *)
|
(** @since 2.8 *)
|
||||||
|
|
||||||
val std_seq : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) Seq.t
|
val seq : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) Seq.t
|
||||||
(** @since 2.8 *)
|
(** Renamed from [std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
(** {4 Copying functions}
|
(** {4 Copying functions}
|
||||||
|
|
||||||
|
|
@ -380,8 +383,9 @@ module Split : sig
|
||||||
val iter_cpy : ?drop:drop_if_empty -> by:string -> string -> string iter
|
val iter_cpy : ?drop:drop_if_empty -> by:string -> string -> string iter
|
||||||
(** @since 2.8 *)
|
(** @since 2.8 *)
|
||||||
|
|
||||||
val std_seq_cpy : ?drop:drop_if_empty -> by:string -> string -> string Seq.t
|
val seq_cpy : ?drop:drop_if_empty -> by:string -> string -> string Seq.t
|
||||||
(** @since 2.8 *)
|
(** Renamed from [std_seq_cpy] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val left : by:(string [@keep_label]) -> string -> (string * string) option
|
val left : by:(string [@keep_label]) -> string -> (string * string) option
|
||||||
(** Split on the first occurrence of [by] from the leftmost part of
|
(** Split on the first occurrence of [by] from the leftmost part of
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ let to_iter ?(idx=0) s : uchar iter =
|
||||||
done
|
done
|
||||||
with Stop -> ()
|
with Stop -> ()
|
||||||
|
|
||||||
let to_std_seq ?(idx=0) s : uchar Seq.t =
|
let to_seq ?(idx=0) s : uchar Seq.t =
|
||||||
let rec loop st =
|
let rec loop st =
|
||||||
let r = ref None in
|
let r = ref None in
|
||||||
fun () ->
|
fun () ->
|
||||||
|
|
@ -141,15 +141,15 @@ let to_std_seq ?(idx=0) s : uchar Seq.t =
|
||||||
loop st
|
loop st
|
||||||
|
|
||||||
(*$= & ~cmp:(=) ~printer:Q.Print.(list (fun c -> string_of_int@@ Uchar.to_int c))
|
(*$= & ~cmp:(=) ~printer:Q.Print.(list (fun c -> string_of_int@@ Uchar.to_int c))
|
||||||
(to_list (of_string_exn "aébõ😀")) (to_std_seq (of_string_exn "aébõ😀") |> CCList.of_std_seq)
|
(to_list (of_string_exn "aébõ😀")) (to_seq (of_string_exn "aébõ😀") |> CCList.of_seq)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
(* make sure it's persisted correctly *)
|
(* make sure it's persisted correctly *)
|
||||||
(*$R
|
(*$R
|
||||||
let s = (of_string_exn "aébõ😀") in
|
let s = (of_string_exn "aébõ😀") in
|
||||||
let seq = to_std_seq s in
|
let seq = to_seq s in
|
||||||
let l = to_list s in
|
let l = to_list s in
|
||||||
let testeq seq = assert_equal ~cmp:(=) l (CCList.of_std_seq seq) in
|
let testeq seq = assert_equal ~cmp:(=) l (CCList.of_seq seq) in
|
||||||
testeq seq;
|
testeq seq;
|
||||||
testeq seq;
|
testeq seq;
|
||||||
testeq seq;
|
testeq seq;
|
||||||
|
|
@ -213,7 +213,7 @@ let of_gen g : t =
|
||||||
in
|
in
|
||||||
aux ()
|
aux ()
|
||||||
|
|
||||||
let of_std_seq seq : t =
|
let of_seq seq : t =
|
||||||
let buf = Buffer.create 32 in
|
let buf = Buffer.create 32 in
|
||||||
Seq.iter (code_to_string buf) seq;
|
Seq.iter (code_to_string buf) seq;
|
||||||
Buffer.contents buf
|
Buffer.contents buf
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,11 @@ val to_iter : ?idx:int -> t -> uchar iter
|
||||||
@param idx offset where to start the decoding.
|
@param idx offset where to start the decoding.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val to_std_seq : ?idx:int -> t -> uchar Seq.t
|
val to_seq : ?idx:int -> t -> uchar Seq.t
|
||||||
(** Iter of unicode codepoints.
|
(** Iter of unicode codepoints.
|
||||||
|
Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
@param idx offset where to start the decoding.
|
@param idx offset where to start the decoding.
|
||||||
@since 2.8
|
@since NEXT_RELEASE
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val to_list : ?idx:int -> t -> uchar list
|
val to_list : ?idx:int -> t -> uchar list
|
||||||
|
|
@ -80,9 +81,10 @@ val append : t -> t -> t
|
||||||
|
|
||||||
val concat : t -> t list -> t
|
val concat : t -> t list -> t
|
||||||
|
|
||||||
val of_std_seq : uchar Seq.t -> t
|
val of_seq : uchar Seq.t -> t
|
||||||
(** Build a string from unicode codepoints
|
(** Build a string from unicode codepoints
|
||||||
@since 2.8 *)
|
Renamed from [of_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_iter : uchar iter -> t
|
val of_iter : uchar iter -> t
|
||||||
(** Build a string from unicode codepoints
|
(** Build a string from unicode codepoints
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,7 @@ let remove_unordered v i =
|
||||||
|
|
||||||
let append_iter a i = i (fun x -> push a x)
|
let append_iter a i = i (fun x -> push a x)
|
||||||
|
|
||||||
let append_std_seq a seq = Seq.iter (fun x -> push a x) seq
|
let append_seq a seq = Seq.iter (fun x -> push a x) seq
|
||||||
|
|
||||||
let append_array a b =
|
let append_array a b =
|
||||||
let len_b = Array.length b in
|
let len_b = Array.length b in
|
||||||
|
|
@ -839,12 +839,12 @@ let flat_map_iter f v =
|
||||||
v;
|
v;
|
||||||
v'
|
v'
|
||||||
|
|
||||||
let flat_map_std_seq f v =
|
let flat_map_seq f v =
|
||||||
let v' = create () in
|
let v' = create () in
|
||||||
iter
|
iter
|
||||||
(fun x ->
|
(fun x ->
|
||||||
let seq = f x in
|
let seq = f x in
|
||||||
append_std_seq v' seq)
|
append_seq v' seq)
|
||||||
v;
|
v;
|
||||||
v'
|
v'
|
||||||
|
|
||||||
|
|
@ -941,8 +941,8 @@ let of_iter ?(init=create ()) seq =
|
||||||
append_iter init seq;
|
append_iter init seq;
|
||||||
init
|
init
|
||||||
|
|
||||||
let of_std_seq ?(init=create ()) seq =
|
let of_seq ?(init=create ()) seq =
|
||||||
append_std_seq init seq;
|
append_seq init seq;
|
||||||
init
|
init
|
||||||
|
|
||||||
(*$T
|
(*$T
|
||||||
|
|
@ -957,14 +957,14 @@ let to_iter_rev v k =
|
||||||
k (Array.unsafe_get v.vec i)
|
k (Array.unsafe_get v.vec i)
|
||||||
done
|
done
|
||||||
|
|
||||||
let to_std_seq v =
|
let to_seq v =
|
||||||
let rec aux i () =
|
let rec aux i () =
|
||||||
if i>= size v then Seq.Nil
|
if i>= size v then Seq.Nil
|
||||||
else Seq.Cons (v.vec.(i), aux (i+1))
|
else Seq.Cons (v.vec.(i), aux (i+1))
|
||||||
in
|
in
|
||||||
aux 0
|
aux 0
|
||||||
|
|
||||||
let to_std_seq_rev v =
|
let to_seq_rev v =
|
||||||
let rec aux i () =
|
let rec aux i () =
|
||||||
if i<0 || i > size v then Seq.Nil
|
if i<0 || i > size v then Seq.Nil
|
||||||
else Seq.Cons (v.vec.(i), aux (i-1))
|
else Seq.Cons (v.vec.(i), aux (i-1))
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,10 @@ val append_iter : ('a, rw) t -> 'a iter -> unit
|
||||||
(** Append content of iterator.
|
(** Append content of iterator.
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
|
|
||||||
val append_std_seq : ('a, rw) t -> 'a Seq.t -> unit
|
val append_seq : ('a, rw) t -> 'a Seq.t -> unit
|
||||||
(** Append content of iterator.
|
(** Append content of iterator.
|
||||||
@since 2.8 *)
|
Renamed from [append_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val append_list : ('a, rw) t -> 'a list -> unit
|
val append_list : ('a, rw) t -> 'a list -> unit
|
||||||
(** Append content of list.
|
(** Append content of list.
|
||||||
|
|
@ -209,9 +210,10 @@ val filter_map_in_place : ('a -> 'a option) -> ('a,_) t -> unit
|
||||||
val flat_map : ('a -> ('b,_) t) -> ('a,_) t -> ('b, 'mut) t
|
val flat_map : ('a -> ('b,_) t) -> ('a,_) t -> ('b, 'mut) t
|
||||||
(** Map each element to a sub-vector. *)
|
(** Map each element to a sub-vector. *)
|
||||||
|
|
||||||
val flat_map_std_seq : ('a -> 'b Seq.t) -> ('a,_) t -> ('b, 'mut) t
|
val flat_map_seq : ('a -> 'b Seq.t) -> ('a,_) t -> ('b, 'mut) t
|
||||||
(** Like {!flat_map}, but using [Seq] for intermediate collections.
|
(** Like {!flat_map}, but using [Seq] for intermediate collections.
|
||||||
@since 2.8 *)
|
Renamed from [flat_map_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val flat_map_list : ('a -> 'b list) -> ('a,_) t -> ('b, 'mut) t
|
val flat_map_list : ('a -> 'b list) -> ('a,_) t -> ('b, 'mut) t
|
||||||
(** Like {!flat_map}, but using {!list} for
|
(** Like {!flat_map}, but using {!list} for
|
||||||
|
|
@ -298,9 +300,10 @@ val of_iter : ?init:('a,rw) t -> 'a iter -> ('a, rw) t
|
||||||
(** Convert an Iterator to a vector.
|
(** Convert an Iterator to a vector.
|
||||||
@since 2.8.1 *)
|
@since 2.8.1 *)
|
||||||
|
|
||||||
val of_std_seq : ?init:('a,rw) t -> 'a Seq.t -> ('a, rw) t
|
val of_seq : ?init:('a,rw) t -> 'a Seq.t -> ('a, rw) t
|
||||||
(** Convert an Iterator to a vector.
|
(** Convert an Iterator to a vector.
|
||||||
@since 2.8.1 *)
|
Renamed from [of_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val to_iter : ('a,_) t -> 'a iter
|
val to_iter : ('a,_) t -> 'a iter
|
||||||
(** Return a [iter] with the elements contained in the vector.
|
(** Return a [iter] with the elements contained in the vector.
|
||||||
|
|
@ -313,15 +316,17 @@ val to_iter_rev : ('a,_) t -> 'a iter
|
||||||
@since 2.8
|
@since 2.8
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val to_std_seq : ('a,_) t -> 'a Seq.t
|
val to_seq : ('a,_) t -> 'a Seq.t
|
||||||
(** Return an iterator with the elements contained in the vector.
|
(** Return an iterator with the elements contained in the vector.
|
||||||
@since 2.8
|
Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val to_std_seq_rev : ('a,_) t -> 'a Seq.t
|
val to_seq_rev : ('a,_) t -> 'a Seq.t
|
||||||
(** [to_seq v] returns the sequence of elements of [v] in reverse order,
|
(** [to_seq v] returns the sequence of elements of [v] in reverse order,
|
||||||
that is, the last elements of [v] are iterated on first.
|
that is, the last elements of [v] are iterated on first.
|
||||||
@since 2.8
|
Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val slice : ('a,rw) t -> ('a array * int * int)
|
val slice : ('a,rw) t -> ('a array * int * int)
|
||||||
|
|
@ -329,7 +334,7 @@ val slice : ('a,rw) t -> ('a array * int * int)
|
||||||
be careful!. *)
|
be careful!. *)
|
||||||
|
|
||||||
val slice_iter : ('a,_) t -> int -> int -> 'a iter
|
val slice_iter : ('a,_) t -> int -> int -> 'a iter
|
||||||
(** [slice_seq v start len] is the sequence of elements from [v.(start)]
|
(** [slice_iter v start len] is the sequence of elements from [v.(start)]
|
||||||
to [v.(start+len-1)].
|
to [v.(start+len-1)].
|
||||||
@since NEXT_RELEASE
|
@since NEXT_RELEASE
|
||||||
*)
|
*)
|
||||||
|
|
|
||||||
|
|
@ -117,23 +117,19 @@ let add_iter q seq =
|
||||||
|
|
||||||
let of_iter s = add_iter empty s
|
let of_iter s = add_iter empty s
|
||||||
|
|
||||||
let of_seq = of_iter
|
|
||||||
let to_seq = to_iter
|
|
||||||
let add_seq = add_iter
|
|
||||||
|
|
||||||
(*$Q
|
(*$Q
|
||||||
Q.(list small_int) (fun l -> \
|
Q.(list small_int) (fun l -> \
|
||||||
equal CCInt.equal \
|
equal CCInt.equal \
|
||||||
(of_seq (Iter.of_list l)) \
|
(of_iter (Iter.of_list l)) \
|
||||||
(of_list l))
|
(of_list l))
|
||||||
Q.(list small_int) (fun l -> \
|
Q.(list small_int) (fun l -> \
|
||||||
l = (of_list l |> to_seq |> Iter.to_list))
|
l = (of_list l |> to_iter |> Iter.to_list))
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let add_std_seq q l = add_iter q (fun k -> Seq.iter k l)
|
let add_seq q l = add_iter q (fun k -> Seq.iter k l)
|
||||||
let of_std_seq l = add_std_seq empty l
|
let of_seq l = add_seq empty l
|
||||||
|
|
||||||
let to_std_seq q =
|
let to_seq q =
|
||||||
let rec aux1 l () = match l with
|
let rec aux1 l () = match l with
|
||||||
| [] -> aux2 (List.rev q.tl) ()
|
| [] -> aux2 (List.rev q.tl) ()
|
||||||
| x :: tl -> Seq.Cons (x, aux1 tl)
|
| x :: tl -> Seq.Cons (x, aux1 tl)
|
||||||
|
|
@ -147,7 +143,7 @@ let rec klist_iter_ k f = match k() with
|
||||||
| `Nil -> ()
|
| `Nil -> ()
|
||||||
| `Cons (x,tl) -> f x; klist_iter_ tl f
|
| `Cons (x,tl) -> f x; klist_iter_ tl f
|
||||||
|
|
||||||
let add_klist q l = add_seq q (klist_iter_ l)
|
let add_klist q l = add_iter q (klist_iter_ l)
|
||||||
let of_klist l = add_klist empty l
|
let of_klist l = add_klist empty l
|
||||||
|
|
||||||
let to_klist q =
|
let to_klist q =
|
||||||
|
|
@ -164,7 +160,7 @@ let rec gen_iter g f = match g() with
|
||||||
| None -> ()
|
| None -> ()
|
||||||
| Some x -> f x; gen_iter g f
|
| Some x -> f x; gen_iter g f
|
||||||
|
|
||||||
let add_gen q g = add_seq q (gen_iter g)
|
let add_gen q g = add_iter q (gen_iter g)
|
||||||
let of_gen g = add_gen empty g
|
let of_gen g = add_gen empty g
|
||||||
|
|
||||||
let to_gen q =
|
let to_gen q =
|
||||||
|
|
|
||||||
|
|
@ -88,27 +88,26 @@ val to_iter : 'a t -> 'a iter
|
||||||
val add_iter : 'a t -> 'a iter -> 'a t
|
val add_iter : 'a t -> 'a iter -> 'a t
|
||||||
val of_iter : 'a iter -> 'a t
|
val of_iter : 'a iter -> 'a t
|
||||||
|
|
||||||
val to_seq : 'a t -> 'a sequence
|
val to_seq : 'a t -> 'a Seq.t
|
||||||
[@@ocaml.deprecated "use to_iter"]
|
(** Renamed from [to_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val add_seq : 'a t -> 'a sequence -> 'a t
|
val add_seq : 'a t -> 'a Seq.t -> 'a t
|
||||||
[@@ocaml.deprecated "use add_iter"]
|
(** Renamed from [add_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val of_seq : 'a sequence -> 'a t
|
val of_seq : 'a Seq.t -> 'a t
|
||||||
[@@ocaml.deprecated "use of_iter"]
|
(** Renamed from [of_std_seq] since NEXT_RELEASE.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
val to_std_seq : 'a t -> 'a Seq.t
|
|
||||||
val add_std_seq : 'a t -> 'a Seq.t -> 'a t
|
|
||||||
val of_std_seq : 'a Seq.t -> 'a t
|
|
||||||
|
|
||||||
val to_klist : 'a t -> 'a klist
|
val to_klist : 'a t -> 'a klist
|
||||||
[@@ocaml.deprecated "use to_std_seq"]
|
[@@ocaml.deprecated "use to_seq"]
|
||||||
|
|
||||||
val add_klist : 'a t -> 'a klist -> 'a t
|
val add_klist : 'a t -> 'a klist -> 'a t
|
||||||
[@@ocaml.deprecated "use add_std_seq"]
|
[@@ocaml.deprecated "use add_seq"]
|
||||||
|
|
||||||
val of_klist : 'a klist -> 'a t
|
val of_klist : 'a klist -> 'a t
|
||||||
[@@ocaml.deprecated "use of_std_seq"]
|
[@@ocaml.deprecated "use of_seq"]
|
||||||
|
|
||||||
val of_gen : 'a gen -> 'a t
|
val of_gen : 'a gen -> 'a t
|
||||||
val add_gen : 'a t -> 'a gen -> 'a t
|
val add_gen : 'a t -> 'a gen -> 'a t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue