Move IntPair and PosSet into Aoc library.

These are obviously generic enough and useful for the future that they
can be moved to a shared library.
This commit is contained in:
2024-12-06 17:15:37 +00:00
parent 38d0781c7e
commit 831bbf4f63
3 changed files with 75 additions and 19 deletions

View File

@@ -15,3 +15,62 @@ val main : (string -> 'a) -> (('b -> string) * ('a -> 'b)) list -> unit
pair of functions. The first converts the output to a string (for example
[string_of_int]). The second executes the given part. Output is given as if
done by: [print_string ( prep fname |> snd |> fst )] *)
(** Module representing a pair of integers, useful for Set.Make *)
module IntPair : sig
type t = int * int
(** [t] is a pair of integers *)
val compare : t -> t -> int
(** Standard comparion operation. *)
end
(** IntPairSet represents a Set of integers, see standard docs for info. *)
module IntPairSet : sig
type elt = IntPair.t
type t = Set.Make(IntPair).t
val empty : t
val add : elt -> t -> t
val singleton : elt -> t
val remove : elt -> t -> t
val union : t -> t -> t
val inter : t -> t -> t
val disjoint : t -> t -> bool
val diff : t -> t -> t
val cardinal : t -> int
val elements : t -> elt list
val min_elt : t -> elt
val min_elt_opt : t -> elt option
val max_elt : t -> elt
val max_elt_opt : t -> elt option
val choose : t -> elt
val choose_opt : t -> elt option
val find : elt -> t -> elt
val find_opt : elt -> t -> elt option
val find_first : (elt -> bool) -> t -> elt
val find_first_opt : (elt -> bool) -> t -> elt option
val find_last : (elt -> bool) -> t -> elt
val find_last_opt : (elt -> bool) -> t -> elt option
val iter : (elt -> unit) -> t -> unit
val fold : (elt -> 'acc -> 'acc) -> t -> 'acc -> 'acc
val map : (elt -> elt) -> t -> t
val filter : (elt -> bool) -> t -> t
val filter_map : (elt -> elt option) -> t -> t
val partition : (elt -> bool) -> t -> t * t
val split : elt -> t -> t * bool * t
val is_empty : t -> bool
val mem : elt -> t -> bool
val equal : t -> t -> bool
val compare : t -> t -> int
val subset : t -> t -> bool
val for_all : (elt -> bool) -> t -> bool
val exists : (elt -> bool) -> t -> bool
val to_list : t -> elt list
val of_list : elt list -> t
val to_seq_from : elt -> t -> elt Seq.t
val to_seq : t -> elt Seq.t
val to_rev_seq : t -> elt Seq.t
val add_seq : elt Seq.t -> t -> t
val of_seq : elt Seq.t -> t
end