Liking cljdoc? Tell your friends :D

me.tonsky.persistent-sorted-set

clj

A B-tree based persistent sorted set. Supports transients, custom comparators, fast iteration, efficient slices (iterator over a part of the set) and reverse slices. Almost a drop-in replacement for [[clojure.core/sorted-set]], the only difference being this one can’t store nil.

A B-tree based persistent sorted set. Supports transients, custom comparators, fast iteration, efficient slices (iterator over a part of the set) and reverse slices. Almost a drop-in replacement for [[clojure.core/sorted-set]], the only difference being this one can’t store nil.
cljs

A B-tree based persistent sorted set. Supports transients, custom comparators, fast iteration, efficient slices (iterator over a part of the set) and reverse slices. Almost a drop-in replacement for [[clojure.core/sorted-set]], the only difference being this one can't store nil.

A B-tree based persistent sorted set. Supports transients, custom comparators, fast iteration, efficient slices (iterator over a part of the set) and reverse slices. Almost a drop-in replacement for [[clojure.core/sorted-set]], the only difference being this one can't store nil.
raw docstring

conjclj/s≠

clj
(conj set key cmp)

Analogue to [[clojure.core/conj]] but with comparator that overrides the one stored in set.

Analogue to [[clojure.core/conj]] but with comparator that overrides the one stored in set.
cljs
(conj set key)
(conj set key arg)
(conj set key cmp opts)

Analogue to [[clojure.core/conj]] but with comparator that overrides the one stored in set. returns BTSet by default returns continuation yeilding BTSet when {:sync? false}

Analogue to [[clojure.core/conj]] but with comparator that overrides the one stored in set.
returns BTSet by default
returns continuation yeilding BTSet when {:sync? false}
source (clj)source (cljs)raw docstring

contains?cljs

(contains? set key)
(contains? set key opts)

returns boolean by default returns continuation yeilding boolean when {:sync? false}

returns boolean by default
returns continuation yeilding boolean when {:sync? false}
sourceraw docstring

countcljs

(count set)
(count set opts)

O(n) when restoring root address, otherwise O(1) returns number by default returns continuation yeilding number when {:sync? false}

O(n) when restoring root address, otherwise O(1)
returns number by default
returns continuation yeilding number when {:sync? false}
sourceraw docstring

disjclj/s≠

clj
(disj set key cmp)

Analogue to [[clojure.core/disj]] with comparator that overrides the one stored in set.

Analogue to [[clojure.core/disj]] with comparator that overrides the one stored in set.
cljs
(disj set key)
(disj set key arg)
(disj set key cmp opts)

Analogue to [[clojure.core/disj]] with comparator that overrides the one stored in set. returns BTSet by default returns continuation yeilding BTSet when {:sync? false}

Analogue to [[clojure.core/disj]] with comparator that overrides the one stored in set.
returns BTSet by default
returns continuation yeilding BTSet when {:sync? false}
source (clj)source (cljs)raw docstring

equiv-sequential?cljs

(equiv-sequential? set other)
(equiv-sequential? set other opts)

Test items in sequential order. returns boolean by default returns continuation yeilding boolean when {:sync? false}

Test items in sequential order.
returns boolean by default
returns continuation yeilding boolean when {:sync? false}
sourceraw docstring

equiv?cljs

(equiv? set other)
(equiv? set other opts)

Is other a set with the same items? returns boolean by default returns continuation yeilding boolean when {:sync? false}

Is _other_ a set with the same items?
returns boolean by default
returns continuation yeilding boolean when {:sync? false}
sourceraw docstring

from-sequentialclj/s≠

clj
(from-sequential cmp keys)
(from-sequential cmp keys opts)

Create a set with custom comparator and a collection of keys. Useful when you don’t want to call [[clojure.core/apply]] on sorted-set-by.

Create a set with custom comparator and a collection of keys. Useful when you don’t want to call [[clojure.core/apply]] on [[sorted-set-by]].
cljs
(from-sequential cmp seq)
(from-sequential cmp seq opts)

Create a set with custom comparator and a collection of keys. Useful when you't want to call [[clojure.core/apply]] on sorted-set-by.

Create a set with custom comparator and a collection of keys. Useful when you't want to call [[clojure.core/apply]] on [[sorted-set-by]].
source (clj)source (cljs)raw docstring

from-sorted-arrayclj/s≠

clj
(from-sorted-array cmp keys)
(from-sorted-array cmp keys len)
(from-sorted-array cmp keys len opts)
cljs
(from-sorted-array cmp arr)
(from-sorted-array cmp arr _len)
(from-sorted-array cmp arr _len opts)

Fast path to create a set if you already have a sorted array of elements on your hands.

Fast path to create a set if you already have a sorted array of elements on your hands.
source (clj)source (cljs)raw docstring

intocljs

(into set arg)
(into set arg0 arg1)
(into set xform from opts)

xforms must be synchronous returns collection by default returns continuation yielding collection when {:sync? false}

xforms must be synchronous
returns collection by default
returns continuation yielding collection when {:sync? false}
sourceraw docstring

lookupclj/s≠

clj
(lookup set key)
(lookup set key cmp)

Look up a key and return the actual stored element. Unlike get/valAt which return the search key, this returns the stored element - useful when using custom comparators that only compare part of the key (e.g., [id value] tuples compared by id).

O(log n) traversal with no allocations (unlike slice).

Returns nil if not found.

Look up a key and return the actual stored element.
Unlike get/valAt which return the search key, this returns the
stored element - useful when using custom comparators that only
compare part of the key (e.g., [id value] tuples compared by id).

O(log n) traversal with no allocations (unlike slice).

Returns nil if not found.
cljs
(lookup set key)
(lookup set key not-found)

key if present, else (or not-found nil)

key if present, else (or not-found nil)
source (clj)source (cljs)raw docstring

reducecljs

(reduce arf set from)
(reduce arf set from opts)

reducing function is fn<acc,item> and must return a continuation returns result by default returns continuation yielding result when {:sync? false}

reducing function is fn<acc,item> and _must_ return a continuation
returns result by default
returns continuation yielding result when {:sync? false}
sourceraw docstring

replaceclj/s≠

clj
(replace set old-key new-key)
(replace set old-key new-key cmp)

Replace an existing key with a new key at the same logical position. The comparator must return 0 for both old-key and new-key. This is a single-traversal update - much faster than disj + conj.

O(log n) traversal with minimal allocations.

Returns the updated set, or the original set if old-key not found.

Replace an existing key with a new key at the same logical position.
The comparator must return 0 for both old-key and new-key.
This is a single-traversal update - much faster than disj + conj.

O(log n) traversal with minimal allocations.

Returns the updated set, or the original set if old-key not found.
cljs
(replace set old-key new-key)
(replace set old-key new-key arg)
(replace set old-key new-key cmp opts)

Replace an existing key with a new key at the same logical position. The comparator must return 0 for both old-key and new-key. This is a single-traversal update - faster than disj + conj. returns BTSet by default returns continuation yielding BTSet when {:sync? false}

Replace an existing key with a new key at the same logical position.
The comparator must return 0 for both old-key and new-key.
This is a single-traversal update - faster than disj + conj.
returns BTSet by default
returns continuation yielding BTSet when {:sync? false}
source (clj)source (cljs)raw docstring

restoreclj/s≠

clj
(restore address storage)
(restore address storage opts)

Constructs lazily-loaded set from storage and root address. Supports all operations that normal in-memory impl would, will fetch missing nodes by calling IStorage::restore when needed

Constructs lazily-loaded set from storage and root address.
Supports all operations that normal in-memory impl would,
will fetch missing nodes by calling IStorage::restore when needed
cljs
(restore root-address-or-info storage)
(restore root-address-or-info storage opts)

Restore a set from storage given root-address-or-info and storage. This operation is always synchronous and does not initiate io.

  • First arg can be either:
    • A root address (UUID) - requires opts with :shift and :count
    • A map from store-set with :root-address :comparator

returns BTSet, always synchronously

Restore a set from storage given root-address-or-info and storage.
This operation is always synchronous and does not initiate io.
+ First arg can be either:
  - A root address (UUID) - requires opts with :shift and :count
  - A map from store-set with :root-address :comparator

returns BTSet, **always synchronously**
source (clj)source (cljs)raw docstring

restore-byclj

(restore-by cmp address storage)
(restore-by cmp address storage opts)

Constructs lazily-loaded set from storage, root address and custom comparator. Supports all operations that normal in-memory impl would, will fetch missing nodes by calling IStorage::restore when needed

Constructs lazily-loaded set from storage, root address and custom comparator.
Supports all operations that normal in-memory impl would,
will fetch missing nodes by calling IStorage::restore when needed
sourceraw docstring

rseqcljs

(rseq set)
(rseq set opts)

returns btset/ReverseIter by default returns continuation yielding btset/AsyncRSeq when {:sync? false}

returns btset/ReverseIter by default
returns continuation yielding btset/AsyncRSeq when {:sync? false}
sourceraw docstring

rsliceclj/s≠

clj
(rslice set from to)
(rslice set from to cmp)

A reverse iterator for part of the set with provided boundaries. (rslice set from to) returns backwards iterator for all Xs where from <= X <= to. (rslice set from nil) returns backwards iterator for all Xs where X <= from. Optionally pass in comparator that will override the one that set uses. Supports efficient [[clojure.core/rseq]].

A reverse iterator for part of the set with provided boundaries.
`(rslice set from to)` returns backwards iterator for all Xs where from <= X <= to.
`(rslice set from nil)` returns backwards iterator for all Xs where X <= from.
Optionally pass in comparator that will override the one that set uses. Supports efficient [[clojure.core/rseq]].
cljs
(rslice set key)
(rslice set key-from key-to)
(rslice set key-from key-to arg)
(rslice set key-from key-to cmp opts)

A reverse iterator for part of the set with provided boundaries. (rslice set from to) returns backwards iterator for all Xs where from <= X <= to. Optionally pass in comparator that will override the one that set uses. Supports efficient [[clojure.core/rseq]].

A reverse iterator for part of the set with provided boundaries.
`(rslice set from to)` returns backwards iterator for all Xs where from <= X <= to.
Optionally pass in comparator that will override the one that set uses. Supports efficient [[clojure.core/rseq]].
source (clj)source (cljs)raw docstring

seekclj/s≠

clj
(seek seq to)
(seek seq to cmp)
cljs
(seek seq to)
(seek seq to arg)
(seek seq to cmp opts)

An efficient way to seek to a specific key in a seq (either returned by [[clojure.core.seq]] or a slice.) (seek (seq set) to) returns iterator for all Xs where to <= X. Optionally pass in comparator that will override the one that set uses.

An efficient way to seek to a specific key in a seq (either returned by [[clojure.core.seq]] or a slice.)
`(seek (seq set) to)` returns iterator for all Xs where to <= X.
Optionally pass in comparator that will override the one that set uses.
source (clj)source (cljs)raw docstring

seqcljs

(seq set)
(seq set opts)

returns btset/Iter by default returns continuation yielding btset/AsyncSeq when {:sync? false}

returns btset/Iter by default
returns continuation yielding btset/AsyncSeq when {:sync? false}
sourceraw docstring

settingsclj

(settings set)
source

sliceclj/s≠

clj
(slice set from to)
(slice set from to cmp)

An iterator for part of the set with provided boundaries. (slice set from to) returns iterator for all Xs where from <= X <= to. (slice set from nil) returns iterator for all Xs where X >= from. Optionally pass in comparator that will override the one that set uses. Supports efficient [[clojure.core/rseq]].

An iterator for part of the set with provided boundaries.
`(slice set from to)` returns iterator for all Xs where from <= X <= to.
`(slice set from nil)` returns iterator for all Xs where X >= from.
Optionally pass in comparator that will override the one that set uses. Supports efficient [[clojure.core/rseq]].
cljs
(slice set key-from key-to)
(slice set key-from key-to arg)
(slice set key-from key-to comparator opts)

An iterator for part of the set with provided boundaries. (slice set from to) returns iterator for all Xs where from <= X <= to. Optionally pass in comparator that will override the one that set uses. Supports efficient [[clojure.core/rseq]].

An iterator for part of the set with provided boundaries.
`(slice set from to)` returns iterator for all Xs where from <= X <= to.
Optionally pass in comparator that will override the one that set uses. Supports efficient [[clojure.core/rseq]].
source (clj)source (cljs)raw docstring

sorted-setclj/s≠

(sorted-set)
(sorted-set & keys)
clj

Create a set with default comparator.

Create a set with default comparator.
source (clj)source (cljs)raw docstring

sorted-set*clj/s≠

(sorted-set* opts)
clj

Create a set with custom comparator, metadata and settings

Create a set with custom comparator, metadata and settings
cljs

Create a set with options map containing:

  • :storage Storage implementation
  • :comparator Custom comparator (defaults to compare)
  • :meta Metadata
Create a set with options map containing:
- :storage  Storage implementation
- :comparator  Custom comparator (defaults to compare)
- :meta     Metadata
source (clj)source (cljs)raw docstring

sorted-set-byclj/s≠

(sorted-set-by cmp)
(sorted-set-by cmp & keys)
clj

Create a set with custom comparator.

Create a set with custom comparator.
source (clj)source (cljs)raw docstring

storeclj/s≠

clj
(store set)
(store set storage)

Store each not-yet-stored node by calling IStorage::store and remembering returned address. Incremental, won’t store same node twice on subsequent calls. Returns root address. Remember it and use it for restore

Store each not-yet-stored node by calling IStorage::store and remembering
returned address. Incremental, won’t store same node twice on subsequent calls.
Returns root address. Remember it and use it for restore
cljs
(store set)
(store set arg)
(store set storage opts)

Flush set to storage. sync calls must be used with sync storage and async calls must be used with async storage.

returns address by default returns continuation yeilding address when {:sync? false}

Flush set to storage. sync calls must be used with sync storage
and async calls must be used with async storage.

returns address by default
returns continuation yeilding address when {:sync? false}
source (clj)source (cljs)raw docstring

transducecljs

(transduce xform arf set from)
(transduce xform arf set from opts)

xforms must be synchronous reducing function is fn<acc,item> and must return a continuation returns result by default returns continuation yielding result when {:sync? false}

xforms must be synchronous
reducing function is fn<acc,item> and _must_ return a continuation
returns result by default
returns continuation yielding result when {:sync? false}
sourceraw docstring

walk-addressesclj/s≠

clj
(walk-addresses set consume-fn)

Visit each address used by this set. Usable for cleaning up garbage left in storage from previous versions of the set

Visit each address used by this set. Usable for cleaning up
garbage left in storage from previous versions of the set
cljs
(walk-addresses set consume-fn)
(walk-addresses set consume-fn opts)

Visit each address used by this set. Usable for cleaning up garbage left in storage from previous versions of the set.

returns nil when the walk completes returns a continuation yielding nil when {:sync? false}

Visit each address used by this set. Usable for cleaning up
garbage left in storage from previous versions of the set.

returns nil when the walk completes
returns a continuation yielding nil when {:sync? false}
source (clj)source (cljs)raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close