From be7d94fac44e155b3da6d711d8dcc7040d56c57b Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 18 Jul 2014 01:18:23 +0200 Subject: [PATCH] CCTrie.MakeList/MakeArray --- core/CCTrie.ml | 21 +++++++++++++++++++++ core/CCTrie.mli | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/core/CCTrie.ml b/core/CCTrie.ml index 00926bce..7d762557 100644 --- a/core/CCTrie.ml +++ b/core/CCTrie.ml @@ -417,6 +417,27 @@ module Make(W : WORD) = struct `Node(x, List.map (fun (c,t') -> _tree_node (`Char c) [to_tree t']) l) end +module type ORDERED = sig + type t + val compare : t -> t -> int +end + +module MakeArray(X : ORDERED) = Make(struct + type t = X.t array + type char_ = X.t + let compare = X.compare + let to_seq a k = Array.iter k a + let of_list = Array.of_list +end) + +module MakeList(X : ORDERED) = Make(struct + type t = X.t list + type char_ = X.t + let compare = X.compare + let to_seq a k = List.iter k a + let of_list l = l +end) + module String = Make(struct type t = string type char_ = char diff --git a/core/CCTrie.mli b/core/CCTrie.mli index 38c4a479..de635de2 100644 --- a/core/CCTrie.mli +++ b/core/CCTrie.mli @@ -110,4 +110,13 @@ end module Make(W : WORD) : S with type key = W.t and type char_ = W.char_ +module type ORDERED = sig + type t + val compare : t -> t -> int +end + +module MakeArray(X : ORDERED) : S with type key = X.t array and type char_ = X.t + +module MakeList(X : ORDERED) : S with type key = X.t list and type char_ = X.t + module String : S with type key = string and type char_ = char