alice
library
manual.

Alice Project

The ATOM signature


________ Synopsis ____________________________________________________

    signature ATOM
    structure Atom : ATOM where String = String
  

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

See also: STRING, SUBSTRING, HASHABLE, ORDERED


________ Import ______________________________________________________

    import signature ATOM from "x-alice:/lib/data/ATOM-sig"
    import structure Atom from "x-alice:/lib/data/Atom"

________ Interface ___________________________________________________

    signature ATOM =
    sig
	eqtype string
	eqtype atom
	type t = atom

	val atom :     string -> atom
	val toString : atom -> string

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

________ Description _________________________________________________

eqtype atom type t = atom

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

atom s

Creates an atom with content s. If an atom with the same content already exists, that one is returned.

toString a

Extracts the content of the atom a. It holds that

        toString (atom s) = s
equal (a1, a2)

An explicit equality function on atoms. Equivalent to op=.

compare (a1, a2)

Defines an ordering on atoms. Comparison is intended to be constant time. Note that the ordering is not lexicographic.

hash a

A hash function for atoms. Hashing is constant time.



last modified 2007/Mar/30 17:10