10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-14 18:13:40 +01:00
QCaml/Utils/Zkey.mli

78 lines
2.8 KiB
OCaml
Raw Normal View History

2018-03-03 21:19:50 +01:00
(** Encodes the powers of x, y, z in a compact form, suitable for being
2018-03-09 00:08:12 +01:00
used as keys in a hash table.
Internally, the {Zkey.t} is made of two integers, [left] and [right].
The small integers x, y and z are stored compactly in this 126-bits
space:
{[
Left Right
3 [--------------------------------------------------------------] [------------------|---------------|---------------|---------------]
x y z
6 [--------------------------------------------------------------] [---|----------|----------|----------|----------|----------|---------]
x1 y1 z1 x2 y2 z2
9 [---------------------------------|----------|----------|---------] [---|----------|----------|----------|----------|----------|---------]
x1 y1 z1 x2 y2 z2 x3 y3 z3
12 [---|----------|----------|----------|----------|----------|---------] [---|----------|----------|----------|----------|----------|---------]
x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4
]}
2018-03-09 00:12:00 +01:00
The values of x,y,z should be positive and should not exceed 32767 for
[kind=3]. For all other kinds kinds the values should not exceed 1023.
2018-03-09 00:08:12 +01:00
*)
2018-03-03 21:19:50 +01:00
type t
val to_string : t -> string
(** Pretty printing *)
val of_powers_three : Powers.t -> t
(** Create from a {!Powers.t}. *)
2018-06-29 16:04:40 +02:00
val of_int_four : int -> int -> int -> int -> t
(** Create from four integers. *)
2018-03-03 21:19:50 +01:00
val of_powers_six : Powers.t -> Powers.t -> t
(** Create from two {!Powers.t}. *)
val of_powers_nine : Powers.t -> Powers.t -> Powers.t -> t
(** Create from three {!Powers.t}. *)
val of_powers_twelve : Powers.t -> Powers.t -> Powers.t -> Powers.t -> t
(** Create from four {!Powers.t}. *)
type kind =
| Three of Powers.t
2018-06-29 16:04:40 +02:00
| Four of (int * int * int * int)
2018-03-03 21:19:50 +01:00
| Six of (Powers.t * Powers.t)
| Nine of (Powers.t * Powers.t * Powers.t)
| Twelve of (Powers.t * Powers.t * Powers.t * Powers.t)
val of_powers : kind -> t
(** Create using the [kind] type *)
val to_int_array : t -> int array
(** Convert to an int array. *)
2018-06-29 16:04:40 +02:00
val of_int_array : int array -> t
(** Convert from an int array. *)
2018-03-03 21:19:50 +01:00
val to_powers : t -> kind
(** {1 Functions for hash tables} *)
val hash : t -> int
(** Associates a nonnegative integer to any Zkey. *)
val equal : t -> t -> bool
(** The equal function. True if two Zkeys are equal. *)
val compare : t -> t -> int
(** Comparison function, used for sorting. *)
2018-03-13 18:24:00 +01:00