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.
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.
(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.
(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}(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}(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}(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.
(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}(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}(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}(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]].
(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]].
(from-sorted-array cmp keys)(from-sorted-array cmp keys len)(from-sorted-array cmp keys len opts)(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.
(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}(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.
(lookup set key)(lookup set key not-found)key if present, else (or not-found nil)
key if present, else (or not-found nil)
(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}(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.
(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}(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
(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.
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**
(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
(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}(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]].
(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]].
(seek seq to)(seek seq to cmp)(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.
(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}(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]].
(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]].
(sorted-set)(sorted-set & keys)Create a set with default comparator.
Create a set with default comparator.
(sorted-set* opts)Create a set with custom comparator, metadata and settings
Create a set with custom comparator, metadata and settings
Create a set with options map containing:
Create a set with options map containing: - :storage Storage implementation - :comparator Custom comparator (defaults to compare) - :meta Metadata
(sorted-set-by cmp)(sorted-set-by cmp & keys)Create a set with custom comparator.
Create a set with custom comparator.
(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
(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}(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}(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
(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}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 |