Provides a 'hierarchical set' data structure. See hier-set
for details.
Provides a 'hierarchical set' data structure. See `hier-set` for details.
(hier-set hcontains? & keys)
Constructs a hierarchical set with the containment predicate hcontains?
and primary members keys
. The hcontains?
predicate should be a function of
two arguments over the type of the set elements; it should return true
if the
first argument contains the second, and false otherwise.
A hierarchical set is a set of elements which may hierarchically contain other
elements. The hierarchical relationship is defined by the element sort-order
and the hcontains?
predicate, with the following constraints: (a) elements
must sort prior to any descendants; and (b) elements must contain all elements
which sort between themselves and any descendant. Note that this means
that (hcontains? x x)
must be true, and that elements are thus considered to
be both ancestors and descendants of themselves.
Lookup in the set returns a seq of all primary members which are ancestors of the provided key, or nil if the provided key is not a descendant of any primary member.
Constructs a hierarchical set with the containment predicate `hcontains?` and primary members `keys`. The `hcontains?` predicate should be a function of two arguments over the type of the set elements; it should return `true` if the first argument contains the second, and false otherwise. A hierarchical set is a set of elements which may hierarchically contain other elements. The hierarchical relationship is defined by the element sort-order and the `hcontains?` predicate, with the following constraints: (a) elements must sort prior to any descendants; and (b) elements must contain all elements which sort between themselves and any descendant. Note that this means that `(hcontains? x x)` must be true, and that elements are thus considered to be both ancestors and descendants of themselves. Lookup in the set returns a seq of all primary members which are ancestors of the provided key, or nil if the provided key is not a descendant of any primary member.
(hier-set-by hcontains? comparator & keys)
As hier-set, but specifying the comparator to use for element comparison.
As hier-set, but specifying the comparator to use for element comparison.
Operations on collections defining hierarchical relationships.
Operations on collections defining hierarchical relationships.
(ancestors coll key)
(ancestors coll key strict?)
Return a lazy sequence of all ancestors of key
in coll
. Do not
include key
if strict?
is true, defaulting to false.
Return a lazy sequence of all ancestors of `key` in `coll`. Do not include `key` if `strict?` is true, defaulting to false.
(descendants coll key)
(descendants coll key strict?)
Return a lazy sequence of all descendants of key
in coll
. Do not
include key
if strict?
is true, defaulting to false.
Return a lazy sequence of all descendants of `key` in `coll`. Do not include `key` if `strict?` is true, defaulting to false.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close