Provides secondary index support for clojure data structures.
Provides secondary index support for clojure data structures.
(as-key k)Returns a property that looks up k as a key. Only useful if you are using functions as keys.
Returns a property that looks up k as a key. Only useful if you are using functions as keys.
(ascending coll p test v)Returns an ascending order seq of elements where (test (p element) v) returns true.
The order is defined by the value of v.
This is much like subseq in clojure.core.
Returns an ascending order seq of elements where (test (p element) v) returns true. The order is defined by the value of v. This is much like subseq in clojure.core.
(auto coll)Takes a set, vector or map and wraps it so that its elements support indexed queries.
Indexes are created on demand to satisfy queries and then are reused.
Indexes once realised will be maintained incrementally as you call conj, assoc and so on on the collection.
The coll must be a vector, map or set. If you pass a seq/seqable/iterable it is converted to a vector.
Metadata is carried over to the new structure.
If the collection is already indexed, it is returned as-is without modification.
Takes a set, vector or map and wraps it so that its elements support indexed queries. Indexes are created on demand to satisfy queries and then are reused. Indexes once realised will be maintained incrementally as you call conj, assoc and so on on the collection. The coll must be a vector, map or set. If you pass a seq/seqable/iterable it is converted to a vector. Metadata is carried over to the new structure. If the collection is already indexed, it is returned as-is without modification.
(delete-index coll p kind)(delete-index coll p kind & more)Deletes indexes from the collection, returning a new collection.
Deletes indexes from the collection, returning a new collection.
(descending coll p test v)Returns a descending order seq of elements where (test (p element) v) returns true.
The order is defined by the value of v.
This is much like rsubseq in clojure.core.
Returns a descending order seq of elements where (test (p element) v) returns true. The order is defined by the value of v. This is much like rsubseq in clojure.core.
(identify coll pred)(identify coll p v)Returns the element where the property equals v.
Behaviour is undefined if (p element) does not return a unique value across the collection.
Returns the element where the property equals v. Behaviour is undefined if (p element) does not return a unique value across the collection.
(index coll)(index coll p kind)(index coll p kind & more)Adds indexes to the collection, returning a new indexed collection.
Specify a property/predicate to index, and a kind being:
:idx/unique (for identify and replace-by calls)
:idx/hash (for lookup calls)
:idx/sort (for ascending/descending calls)
The coll must be a vector, map or set. If you pass a seq/seqable/iterable it is converted to a vector.
Metadata is carried over to the new structure.
If the collection is already indexed, it is returned as-is without modification.
Adds indexes to the collection, returning a new indexed collection. Specify a property/predicate to index, and a `kind` being: `:idx/unique` (for identify and replace-by calls) `:idx/hash (for lookup calls)` `:idx/sort` (for ascending/descending calls) The coll must be a vector, map or set. If you pass a seq/seqable/iterable it is converted to a vector. Metadata is carried over to the new structure. If the collection is already indexed, it is returned as-is without modification.
(lookup coll pred)(lookup coll p v)Returns a seq of items where (p element) equals v.
The returned sequence should be considered unsorted.
The 2-ary takes a 'predicate' which composes a property with its expected value, either a (match) form, or a (pred) form.
Returns a seq of items where (p element) equals v. The returned sequence should be considered unsorted. The 2-ary takes a 'predicate' which composes a property with its expected value, either a `(match)` form, or a `(pred)` form.
(lookup-keys coll pred)(lookup-keys coll p v)Like lookup but returns you the index or key of the elements rather than the elements themselves
Like lookup but returns you the index or key of the elements rather than the elements themselves
(match p v & more)Takes a map of {property value-or-predicate} and returns a predicate.
You can then use it in short-form lookup/identify calls.
(lookup coll (match :name "Fred", :age 42)))
If each property value-or-predicate pair matches, the element is returned.
This allows you to use composite indexes.
When indexing manually, index a match by putting the placeholder :idx/value in each value position.
e.g
(idx coll (match :foo :idx/value, :bar :idx/value))
Takes a map of {property value-or-predicate} and returns a predicate.
You can then use it in short-form lookup/identify calls.
(lookup coll (match :name "Fred", :age 42)))
If each property value-or-predicate pair matches, the element
is returned.
This allows you to use composite indexes.
When indexing manually, index a match by putting the placeholder :idx/value in each value position.
e.g
(idx coll (match :foo :idx/value, :bar :idx/value))(path p)(path p1 p2)(path p1 p2 p3)(path p1 p2 p3 p4 & more)Returns a property that will drill down to some nested value by using the properties in the list. Think get-in.
Returns a property that will drill down to some nested value by using the properties in the list. Think get-in.
(pcomp p1 p2)Like clojure.core/comp but on properties.
Like clojure.core/comp but on properties.
(pk coll pred)(pk coll p v)Returns the key (index/map key) given a unique property/value pair or predicate.
Returns the key (index/map key) given a unique property/value pair or predicate.
(pred p)(pred p v)Can be used in matches to nest truthy/falsey predicates.
When you want to test truthyness (pred p) or (pred p true), if you want to test falseyness (pred p false).
Can be used in matches to nest truthy/falsey predicates. When you want to test truthyness (pred p) or (pred p true), if you want to test falseyness (pred p false).
(replace-by coll pred element)(replace-by coll p v element)Replaces an element by an alternative key.
e.g (replace-by customers :id 42 new-customer)
Would return a new collection where the element identified by :id = 42 has been replaced by the value 'new-customer'.
Behaviour is undefined if (p element) does not return a unique value across the collection.
Replaces an element by an alternative key. e.g (replace-by customers :id 42 new-customer) Would return a new collection where the element identified by :id = 42 has been replaced by the value 'new-customer'. Behaviour is undefined if (p element) does not return a unique value across the collection.
(unwrap coll)Returns the backing collection without indexes.
Returns the backing collection without indexes.
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 |