CCTrie.MakeList/MakeArray

This commit is contained in:
Simon Cruanes 2014-07-18 01:18:23 +02:00
parent 5dc0155ab0
commit be7d94fac4
2 changed files with 30 additions and 0 deletions

View file

@ -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

View file

@ -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