alice
library
manual.

Alice Project

The UNIQUE_STRING signature


________ Synopsis ____________________________________________________

    signature UNIQUE_STRING
    structure UniqueString : UNIQUE_STRING where String = String
    structure WideUniqueString : UNIQUE_STRING where String = WideString
  

This structure provides an efficient representation for strings that guarantees that equal strings share their representation. Such strings are also known as internalized string or symbols.

See also: STRING, SUBSTRING


________ Import ______________________________________________________

Imported implicitly.


________ Interface ___________________________________________________

    signature UNIQUE_STRING =
    sig
	eqtype string
	eqtype unique_string
	type t = unique_string

	val unique :  string -> unique_string
	val string :  unique_string -> string

	val equal :   unique_string * unique_string -> bool
	val compare : unique_string * unique_string -> order
	val hash :    unique_string -> int
    end
  

________ Description _________________________________________________

eqtype unique_string type t = unique_string

The type of uniquely represented strings. Equality is defined structurally.

unique s

Creates a unique string with content s. If a unique string with the same content already exists, that one is returned.

string us

Extracts the content of the unique string s. It holds that

        string (unique s) = s
equal (us1, us2)

An explicit equality function on unique strings. Equivalent to op=.

compare (us1, us2)

Performs a lexicographic comparison of the content of the unique strings. Equivalent to

        compare (string us1, string us2)
hash us

A hash function for unique strings. Hashing is constant time.



last modified 1970/01/01 01:00