An implementation of persistent sorted maps and sets based on AVL trees which can be used as drop-in replacements for Clojure's built-in sorted maps and sets based on red-black trees. Apart from the standard sorted collection API, the provided map and set types support the transients API and several additional logarithmic time operations: rank queries via clojure.core/nth (select element by rank) and clojure.data.avl/rank-of (discover rank of element), "nearest key" lookups via clojure.data.avl/nearest, splits by key and index via clojure.data.avl/split-key and clojure.data.avl/split-at, respectively, and subsets/submaps using clojure.data.avl/subrange.
An implementation of persistent sorted maps and sets based on AVL trees which can be used as drop-in replacements for Clojure's built-in sorted maps and sets based on red-black trees. Apart from the standard sorted collection API, the provided map and set types support the transients API and several additional logarithmic time operations: rank queries via clojure.core/nth (select element by rank) and clojure.data.avl/rank-of (discover rank of element), "nearest key" lookups via clojure.data.avl/nearest, splits by key and index via clojure.data.avl/split-key and clojure.data.avl/split-at, respectively, and subsets/submaps using clojure.data.avl/subrange.
(nearest coll test x)(alpha)
Equivalent to, but more efficient than, (first (subseq* coll test x)), where subseq* is clojure.core/subseq for test in #{>, >=} and clojure.core/rsubseq for test in #{<, <=}.
(alpha)
Equivalent to, but more efficient than, (first (subseq* coll test x)),
where subseq* is clojure.core/subseq for test in #{>, >=} and
clojure.core/rsubseq for test in #{<, <=}.(rank-of coll x)Returns the rank of x in coll or -1 if not present.
Returns the rank of x in coll or -1 if not present.
(sorted-map & keyvals)keyval => key val Returns a new AVL map with supplied mappings.
keyval => key val Returns a new AVL map with supplied mappings.
(sorted-map-by comparator & keyvals)keyval => key val Returns a new sorted map with supplied mappings, using the supplied comparator.
keyval => key val Returns a new sorted map with supplied mappings, using the supplied comparator.
(sorted-set & keys)Returns a new sorted set with supplied keys.
Returns a new sorted set with supplied keys.
(sorted-set-by comparator & keys)Returns a new sorted set with supplied keys, using the supplied comparator.
Returns a new sorted set with supplied keys, using the supplied comparator.
(split-at n coll)(alpha)
Equivalent to, but more efficient than, [(into (empty coll) (take n coll)) (into (empty coll) (drop n coll))].
(alpha) Equivalent to, but more efficient than, [(into (empty coll) (take n coll)) (into (empty coll) (drop n coll))].
(split-key k coll)(alpha)
Returns [left e? right], where left and right are collections of the same type as coll and containing, respectively, the keys below and above k in the ordering determined by coll's comparator, while e? is the entry at key k for maps, the stored copy of the key k for sets, nil if coll does not contain k.
(alpha) Returns [left e? right], where left and right are collections of the same type as coll and containing, respectively, the keys below and above k in the ordering determined by coll's comparator, while e? is the entry at key k for maps, the stored copy of the key k for sets, nil if coll does not contain k.
(subrange coll test limit)(subrange coll start-test start end-test end)(alpha)
Returns an AVL collection comprising the entries of coll between start and end (in the sense determined by coll's comparator) in logarithmic time. Whether the endpoints are themselves included in the returned collection depends on the provided tests; start-test must be either > or >=, end-test must be either < or <=.
When passed a single test and limit, subrange infers the other end of the range from the test: > / >= mean to include items up to the end of coll, < / <= mean to include items taken from the beginning of coll.
(subrange coll >= start <= end) is equivalent to, but more efficient than, (into (empty coll) (subseq coll >= start <= end)).
(alpha) Returns an AVL collection comprising the entries of coll between start and end (in the sense determined by coll's comparator) in logarithmic time. Whether the endpoints are themselves included in the returned collection depends on the provided tests; start-test must be either > or >=, end-test must be either < or <=. When passed a single test and limit, subrange infers the other end of the range from the test: > / >= mean to include items up to the end of coll, < / <= mean to include items taken from the beginning of coll. (subrange coll >= start <= end) is equivalent to, but more efficient than, (into (empty coll) (subseq coll >= start <= end)).
(alpha)
Returns an AVL collection comprising the entries of coll between start and end (in the sense determined by coll's comparator) in logarithmic time. Whether the endpoints are themselves included in the returned collection depends on the provided tests; start-test must be either > or >=, end-test must be either < or <=.
When passed a single test and limit, subrange infers the other end of the range from the test: > / >= mean to include items up to the end of coll, < / <= mean to include items taken from the beginning of coll.
(subrange coll >= start <= end) is equivalent to, but more efficient than, (into (empty coll) (subseq coll >= start <= end).
(alpha) Returns an AVL collection comprising the entries of coll between start and end (in the sense determined by coll's comparator) in logarithmic time. Whether the endpoints are themselves included in the returned collection depends on the provided tests; start-test must be either > or >=, end-test must be either < or <=. When passed a single test and limit, subrange infers the other end of the range from the test: > / >= mean to include items up to the end of coll, < / <= mean to include items taken from the beginning of coll. (subrange coll >= start <= end) is equivalent to, but more efficient than, (into (empty coll) (subseq coll >= start <= end).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |