File: trie.mli

package info (click to toggle)
coq 8.16.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 40,596 kB
  • sloc: ml: 219,376; sh: 3,545; python: 3,231; ansic: 2,529; makefile: 767; lisp: 279; javascript: 63; xml: 24; sed: 2
file content (63 lines) | stat: -rw-r--r-- 2,058 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
(************************************************************************)
(*         *   The Coq Proof Assistant / The Coq Development Team       *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)

(** Generic functorized trie data structure. *)

module type S =
sig
  (** A trie is a generalization of the map data structure where the keys are
      themselves lists. *)

  type label
  (** Keys of the trie structure are [label list]. *)

  type data
  (** Data on nodes of tries are finite sets of [data]. *)

  type t
  (** The trie data structure. Essentially a finite map with keys [label list]
      and content [data Set.t]. *)

  val empty : t
  (** The empty trie. *)

  val get : t -> data
  (** Get the data at the current node. *)

  val next : t -> label -> t
  (** [next t lbl] returns the subtrie of [t] pointed by [lbl].
      @raise Not_found if there is none. *)

  val labels : t -> label list
  (** Get the list of defined labels at the current node. *)

  val add : label list -> data -> t -> t
  (** [add t path v] adds [v] at path [path] in [t]. *)

  val remove : label list -> data -> t -> t
  (** [remove t path v] removes [v] from path [path] in [t]. *)

  val iter : (label list -> data -> unit) -> t -> unit
  (** Apply a function to all contents. *)

end

module type Grp =
sig
  type t
  val nil : t
  val is_nil : t -> bool
  val add : t -> t -> t
  val sub : t -> t -> t
end

module Make (Label : Set.OrderedType) (Data : Grp) : S
  with type label = Label.t and type data = Data.t
(** Generating functor, for a given type of labels and data. *)