Liking cljdoc? Tell your friends :D

bortexz.utils.avl

Utilities to work with data.avl sorted collections

Utilities to work with data.avl sorted collections
raw docstring

-EntryKeycljprotocol

Protocol to make some fns work both on sorted maps and sorted sets. For sorted maps, will return the key of the entry. For sorted sets, the entry is the key.

Protocol to make some fns work both on sorted maps and sorted sets.
For sorted maps, will return the key of the entry.
For sorted sets, the entry is the key.

-entry-keyclj

(-entry-key this entry)
sourceraw docstring

-full-tail-vec-fnclj

(-full-tail-vec-fn f)

Returns a full-tail function where items are mapped using f when building the resulting vector.

Returns a [[full-tail]] function where items are mapped using `f` when building the resulting vector.
sourceraw docstring

-tail-vec-fnclj

(-tail-vec-fn f)

Returns a tail function where items are mapped using f when building the resulting vector.

Returns a [[tail]] function where items are mapped using `f` when building the resulting vector.
sourceraw docstring

datafy-avl!clj

(datafy-avl!)
Calls both [[datafy-avl-maps!]] and [[datafy-avl-sets!]]
sourceraw docstring

datafy-avl-maps!clj

(datafy-avl-maps!)

Makes clojure.data.avl.AVLMap implement p/Datafiable. datafy on an AVLMap will return a clojure.core sorted-map.

Makes clojure.data.avl.AVLMap implement p/Datafiable. datafy on an AVLMap will return a clojure.core
sorted-map.
sourceraw docstring

datafy-avl-sets!clj

(datafy-avl-sets!)

Makes clojure.data.avl.AVLSet implement p/Datafiable. datafy on an AVLMap will return a clojure.core sorted-set

Makes clojure.data.avl.AVLSet implement p/Datafiable. datafy on an AVLMap will return a clojure.core
sorted-set
sourceraw docstring

find-valclj

(find-val sm testf)
(find-val sm
          testf
          {:keys [start-rank end-rank]
           :or {start-rank 0 end-rank (dec (count sm))}})

Iterates over sorted-map sm testing vals against previous found val using 2-arity testf, fn accepting new val and previously found val. if testf returns logical true, then the new tested val will be the found val, used to test against following vals. Iteration starts on the second val, and the first val is used as the starting found val. Only tests non-nil values. Returns a tuple [found-rank found-val] if val is non-nil, nil otherwise.

Can optionally specify a map of options including:

  • start-rank start rank of the iteration (included). Defaults to 0.
  • end-rank last rank of the iteration (included). Defaults to latest-rank (dec (count sm))

E.g. find the maximum value and its rank of a sorted-map bounded by 2 ranks, returning first value found for the max value: (find-val sm > {:start-rank 1 :end-rank 10}) (if >= used then latest max-value is returned)

Iterates over sorted-map `sm` testing vals against previous found val using 2-arity `testf`, fn accepting new
val and previously found val. if `testf` returns logical true, then the new tested val will be the found val, used to
test against following vals. Iteration starts on the second val, and the first val is used as the starting found val.
Only tests non-nil values. Returns a tuple [found-rank found-val] if val is non-nil, nil otherwise.

Can optionally specify a map of options including:
- `start-rank` start rank of the iteration (included). Defaults to 0.
- `end-rank` last rank of the iteration (included). Defaults to latest-rank `(dec (count sm))`

E.g. find the maximum value and its rank of a sorted-map bounded by 2 ranks, returning first value found for the max
value:
`(find-val sm > {:start-rank 1 :end-rank 10})` (if >= used then latest max-value is returned)
sourceraw docstring

firstclj

(first sc)

Returns the first element of sorted collection sc if not empty, else nil.

Returns the first element of sorted collection `sc` if not empty, else nil.
sourceraw docstring

first-keyclj

(first-key sm)

Returns the first key of sorted map sm, or nil if empty. Same as (some-> (first sm) key)

Returns the first key of sorted map `sm`, or nil if empty.
Same as (some-> (first sm) key)
sourceraw docstring

first-valclj

(first-val sm)

Returns the first val of sorted map sm, or nil if empty. Same as (some-> (first sm) val)

Returns the first val of sorted map `sm`, or nil if empty.
Same as (some-> (first sm) val)
sourceraw docstring

full-tailclj

source

full-tail-keysclj

source

full-tail-sortedclj

(full-tail-sorted sm n)
(full-tail-sorted sm n end-k)

Faster (some->> (full-tail sc n) (into (avl/sorted-map))). See full-tail

Faster (some->> (full-tail sc n) (into (avl/sorted-map))). See [[full-tail]]
sourceraw docstring

full-tail-valsclj

source

index-byclj

(index-by f coll)
(index-by cmp f coll)

Given an (optional) comparator cmp, function f and coll, creates a new sorted-map whose keys are obtained by calling f on each coll element and vals are the element untouched.

Given an (optional) comparator `cmp`, function `f` and `coll`, creates a new sorted-map whose keys
are obtained by calling `f` on each `coll` element and vals are the element untouched.
sourceraw docstring

lastclj

(last sc)

Returns the last element of sorted collection sc, or nil if sc is empty.

Returns the last element of sorted collection `sc`, or nil if sc is empty.
sourceraw docstring

last-keyclj

(last-key sc)

Returns last key of sorted map sm, or nil if sm is empty. Same as (some-> (last sm) key)

Returns last key of sorted map `sm`, or nil if `sm` is empty.
Same as (some-> (last sm) key)
sourceraw docstring

last-valclj

(last-val sc)

Returns last key of sorted map sm, or nil if sm is empty. Same as (some-> (last sm) val)

Returns last key of sorted map `sm`, or nil if `sm` is empty.
Same as (some-> (last sm) val)
sourceraw docstring

nearest-keyclj

(nearest-key sm test k)

Same as (some-> (avl/nearest sm test k) key).

Same as (some-> (avl/nearest sm test k) key).
sourceraw docstring

nearest-rankclj

(nearest-rank sc test k)

Returns the rank of the nearest key. Same as (rank-of sc (nearest-key sc test k))

Returns the rank of the nearest key.
Same as (rank-of sc (nearest-key sc test k))
sourceraw docstring

nearest-valclj

(nearest-val sm test k)

Same as (some-> (avl/nearest sm test k) val).

Same as (some-> (avl/nearest sm test k) val).
sourceraw docstring

nthclj

(nth sc idx)

Like clojure.core/nth, except it always returns nil if index ouf of bounds.

Like clojure.core/nth, except it always returns nil if index ouf of bounds.
sourceraw docstring

nth-keyclj

(nth-key sm idx)

Returns key at idx for sorted map sm if it exists, otherwise nil. Same as (some-> (nth sc idx nil) key)

Returns key at `idx` for sorted map `sm` if it exists, otherwise nil.
Same as (some-> (nth sc idx nil) key)
sourceraw docstring

nth-valclj

(nth-val sc idx)

Returns val at idx for sorted map sm if it exists, otherwise nil. Same as (some-> (nth sc idx nil) val)

Returns val at `idx` for sorted map `sm` if it exists, otherwise nil.
Same as (some-> (nth sc idx nil) val)
sourceraw docstring

offsetclj

(offset sc k n)

Takes the item that is n items away from k. If k or the resulting item do not exist, returns nil. e.g. (offset sc k -1) takes the previous item to key k e.g. (offset sc k 1) takes the next item to key k.

Takes the item that is `n` items away from `k`. If `k` or the resulting item do not exist, returns nil.
e.g. (offset sc k -1) takes the previous item to key `k`
e.g. (offset sc k 1) takes the next item to key `k`.
sourceraw docstring

offset-keyclj

(offset-key sm k n)

Same as (some-> (offset sc k n) key)

Same as (some-> (offset sc k n) key)
sourceraw docstring

offset-valclj

(offset-val sm k n)

Same as (some-> (offset sc k n) val)

Same as (some-> (offset sc k n) val)
sourceraw docstring

rank-ofclj

(rank-of sc k)

like avl/rank-of, but returns nil instead of -1 when item not found

like avl/rank-of, but returns nil instead of -1 when item not found
sourceraw docstring

tailclj

source

tail-keysclj

source

tail-sortedclj

(tail-sorted sc n)
(tail-sorted sc n end-k)

Like tail but returns an avl sorted collection. Usually faster than (into (sorted-map) (tail sc n)), except when the resulting collection is very small ~(< 10 items)

Like [[tail]] but returns an avl sorted collection.
Usually faster than (into (sorted-map) (tail sc n)),
except when the resulting collection is very small ~(< 10 items)
sourceraw docstring

tail-valsclj

source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close