ATSLIB/libats/funset_avltree

This package implements functional sets based on AVL-trees.
  • set
  • set_type
  • compare_elt_elt
  • funset_nil
  • funset_make_nil
  • funset_sing
  • funset_make_sing
  • funset_make_list
  • funset_is_nil
  • funset_isnot_nil
  • funset_size
  • funset_is_member
  • funset_isnot_member
  • funset_insert
  • funset_remove
  • funset_getmax
  • funset_getmax_opt
  • funset_getmin
  • funset_getmin_opt
  • funset_takeoutmax
  • funset_takeoutmax_opt
  • funset_takeoutmin
  • funset_takeoutmin_opt
  • funset_union
  • funset_intersect
  • funset_diff
  • funset_symdiff
  • funset_equal
  • funset_compare
  • funset_is_subset
  • funset_is_supset
  • fprint_funset
  • fprint_funset$sep
  • funset_foreach
  • funset_foreach_env
  • funset_foreach$fwork
  • funset_listize
  • funset_flistize
  • funset_flistize$fopr
  • funset_avltree_height

  • set

    Synopsis

    typedef set (a:t0p) = set_type (a)

    Description

    The type constructor set is a shorthand for set_type.

    set_type

    Synopsis

    abstype
    set_type (a:t@ype+) = ptr

    compare_elt_elt

    Synopsis

    fun{a:t0p}
    compare_elt_elt (x1: a, x2: a):<> int

    Description

    This function is for comparing elements in sets.

    funset_nil

    Synopsis

    fun{}
    funset_nil {a:t0p} ():<> set(a)

    Description

    This function forms an empty set.

    funset_make_nil

    Synopsis

    fun{}
    funset_make_nil {a:t0p} ():<> set(a)

    Description

    This function is the same as funset_nil.

    funset_sing

    Synopsis

    fun{a:t0p}
    funset_sing (x0: a):<> set(a) // singleton set

    Description

    Given an element x, this function forms the singleton set containing x.

    funset_make_sing

    Synopsis

    fun{a:t0p}
    funset_make_sing (x0: a):<> set(a) // singleton set

    Description

    This function is the same as funset_sing.

    funset_make_list

    Synopsis

    fun{a:t0p}
    funset_make_list (xs: List(INV(a))):<> set(a)

    Description

    Given a list xs, this function forms the set consisting of elements in xs. Note that duplicated elements in xs are all removed in the formed set.

    funset_is_nil

    Synopsis

    fun{}
    funset_is_nil {a:t0p} (xs: set(INV(a))):<> bool

    funset_isnot_nil

    Synopsis

    fun{}
    funset_isnot_nil {a:t0p} (xs: set(INV(a))):<> bool

    funset_size

    Synopsis

    fun{a:t0p}
    funset_size (xs: set(INV(a))):<> size_t

    Description

    This function returns the size of a given set xs. Its time complexity is O(n).

    funset_is_member

    Synopsis

    fun{a:t0p}
    funset_is_member (xs: set(INV(a)), x0: a):<> bool

    Description

    This function tests whether an element occurs in a given set xs. The time complexity of this function is O(log(n)).

    funset_isnot_member

    Synopsis

    fun{a:t0p}
    funset_isnot_member (xs: set(INV(a)), x0: a):<> bool

    Description

    This function tests whether an element does not occur in a given set xs. The time complexity of this function is O(log(n)).

    funset_insert

    Synopsis

    fun{a:t0p}
    funset_insert
      (xs: &set(INV(a)) >> _, x0: a):<!wrt> bool(*[x0] in [xs]*)

    Description

    This function adds an element to a given set xs. The time complexity of this function is O(log(n)).

    Return Value

    The function returns a boolean value indicating whether the element is already in the set xs.

    funset_remove

    Synopsis

    fun{a:t0p}
    funset_remove
      (xs: &set(INV(a)) >> _, x0: a):<!wrt> bool(*[x0] in [xs]*)

    Description

    This function removes an element from a given set xs. The time complexity of this function is O(log(n)).

    Return Value

    The function returns a boolean value indicating whether the element is actually removed from the set xs.

    funset_getmax

    Synopsis

    fun{a:t0p}
    funset_getmax
    (
      xs: set(INV(a)), x0: &a? >> opt(a, b)
    ) :<!wrt> #[b:bool] bool(b) // endfun

    funset_getmax_opt

    Synopsis

    fun{a:t0p}
    funset_getmax_opt (xs: set(INV(a))):<> Option_vt (a)

    funset_getmin

    Synopsis

    fun{a:t0p}
    funset_getmin
    (
      xs: set(INV(a)), x0: &a? >> opt(a, b)
    ) :<!wrt> #[b:bool] bool(b) // endfun

    funset_getmin_opt

    Synopsis

    fun{a:t0p}
    funset_getmin_opt (xs: set(INV(a))):<> Option_vt (a)

    funset_takeoutmax

    Synopsis

    fun{a:t0p}
    funset_takeoutmax
    (
      xs: &set(INV(a)) >> _, x0: &a? >> opt(a, b)
    ) :<!wrt> #[b:bool] bool (b)

    funset_takeoutmax_opt

    Synopsis

    fun{a:t0p}
    funset_takeoutmax_opt (xs: &set(INV(a)) >> _):<> Option_vt(a)

    funset_takeoutmin

    Synopsis

    fun{a:t0p}
    funset_takeoutmin
    (
      xs: &set(INV(a)) >> _, x0: &a? >> opt(a, b)
    ) :<!wrt> #[b:bool] bool (b)

    funset_takeoutmin_opt

    Synopsis

    fun{a:t0p}
    funset_takeoutmin_opt (xs: &set(INV(a)) >> _):<> Option_vt(a)

    funset_union

    Synopsis

    fun{a:t0p}
    funset_union (xs1: set(INV(a)), xs2: set(a)):<> set(a)

    Description

    Given sets xs1 and xs2, this function returns the union of xs1 and xs2.

    funset_intersect

    Synopsis

    fun{a:t0p}
    funset_intersect (xs1: set(INV(a)), xs2: set(a)):<> set(a)

    Description

    Given sets xs1 and xs2, this function returns the intersection of xs1 and xs2.

    funset_diff

    Synopsis

    Synopsis for [funset_diff] is unavailable.

    Description

    Given sets xs1 and xs2, this function returns the difference of xs1 from xs2.

    funset_symdiff

    Synopsis

    fun{a:t0p}
    funset_symdiff (xs1: set(INV(a)), xs2: set(a)):<> set(a)

    Description

    Given sets xs1 and xs2, this function returns the symmetric difference between xs1 and xs2.

    funset_equal

    Synopsis

    fun{a:t0p}
    funset_equal (xs1: set(INV(a)), xs2: set(a)):<> bool

    Description

    This function tests whether two given sets xs1 and xs2 are equal.

    funset_compare

    Synopsis

    fun{a:t0p}
    funset_compare (xs1: set(INV(a)), xs2: set(a)):<> Sgn

    Description

    This function compares two given sets xs1 and xs2 based on the ordering induced from the one (implemented by compare_elt_elt) on set elements.

    funset_is_subset

    Synopsis

    fun{a:t0p}
    funset_is_subset (xs1: set(INV(a)), xs2: set(a)):<> bool

    Description

    Given sets xs1 and xs2, this function tests whether xs1 is a subset of xs2.

    funset_is_supset

    Synopsis

    fun{a:t0p}
    funset_is_supset (xs1: set(INV(a)), xs2: set(a)):<> bool

    Description

    Given sets xs1 and xs2, this function tests whether xs1 is a superset of xs2.

    fprint_funset

    Synopsis

    fun{a:t0p}
    fprint_funset
      (out: FILEref, xs: set(INV(a))): void

    Description

    This function prints out the elements in a given set. It calls fprint_funset$sep to print a separator between every two consecutive elements.

    fprint_funset$sep

    Synopsis

    fun{}
    fprint_funset$sep
      (out: FILEref): void // ", "

    Description

    This function template is called by fprint_funset. It prints out the string ", " (a comma followed by a space character) by default.

    funset_foreach

    Synopsis

    fun{a:t0p}
    funset_foreach (set: set(INV(a))): void

    funset_foreach_env

    Synopsis

    fun{
    a:t0p}{env:vt0p
    } funset_foreach_env
      (set: set(INV(a)), env: &(env) >> _): void

    funset_foreach$fwork

    Synopsis

    fun{
    a:t0p}{env:vt0p
    } funset_foreach$fwork
      (x: a, env: &(env) >> _): void

    funset_listize

    Synopsis

    fun{a:t0p}
    funset_listize(xs: set(INV(a))):<!wrt> List0_vt(a)

    Description

    Given a set xs, this function returns a linear list consisting of all the elements in xs.

    funset_flistize

    Synopsis

    fun{
    a:t0p}{b:t0p
    } funset_flistize (xs: set(INV(a))): List0_vt(b)

    Description

    Given a set xs, this function returns a linear list consisting of all the elements returned by calling funset_flistize$fopr on elements in xs.

    funset_flistize$fopr

    Synopsis

    fun{
    a:t0p}{b:t0p
    } funset_flistize$fopr(x: a): b

    funset_avltree_height

    Synopsis

    fun{a:t0p}
    funset_avltree_height (xs: set (a)):<> intGte (0)

    Description

    Given a set represented by some AVL-tree, this function returns the height of the tree.
    This page is created with ATS by Hongwei Xi and also maintained by Hongwei Xi. SourceForge.net Logo