Module HString

Perfect shared strings by hashconsing

author
Christoph Sticksel
type t

Hashconsed string

Hashtables, maps and sets

val compare : t -> t -> int

Comparison function on hashconsed strings

val equal : t -> t -> bool

Equality function on hashconsed strings

val hash : t -> int

Hashing function on hashconsed strings

module HStringHashtbl : Stdlib.Hashtbl.S with type HStringHashtbl.key = t

Hash table over hashconsed strings

module HStringSet : Stdlib.Set.S with type HStringSet.elt = t

Set over hashconsed strings

module HStringMap : Stdlib.Map.S with type HStringMap.key = t

Map over hashconsed strings

Constructor

val mk_hstring : string -> t

Hashcons a string

val import : t -> t

Import a string from a different instance into this hashcons table

String functions

Omitted functions from the String module in the standard library:

  • copy: All strings are shared

Modified signature:

  • sub: return a string, not a hashconsed string
  • fill, blit: no in-place modifications
val length : t -> int
val get : t -> int -> char
val set : t -> int -> char -> t
val create : int -> t
val make : int -> char -> t
val sub : t -> int -> int -> string
val fill : t -> int -> int -> char -> t
val blit : t -> int -> t -> int -> int -> t
val concat : t -> t list -> t
val iter : (char -> unit) -> t -> unit
val iteri : (int -> char -> unit) -> t -> unit
val map : (char -> char) -> t -> t
val trim : t -> t
val escaped : t -> t
val index : t -> char -> int
val rindex : t -> char -> int
val index_from : t -> int -> char -> int
val rindex_from : t -> int -> char -> int
val contains : t -> char -> bool
val contains_from : t -> int -> char -> bool
val rcontains_from : t -> int -> char -> bool
val uppercase : t -> t
val lowercase : t -> t
val capitalize : t -> t
val uncapitalize : t -> t

Pretty-printing

val pp_print_hstring : Stdlib.Format.formatter -> t -> unit

Pretty-print a hashconsed string

val print_hstring : t -> unit

Pretty-print a hashconsed term to the standard formatter

val string_of_hstring : t -> string

Return the string