Liking cljdoc? Tell your friends :D

ham-fisted.api

Fast mutable and immutable associative data structures based on bitmap trie hashmaps. Mutable pathways implement the java.util.Map or Set interfaces including in-place update features such as compute or computeIfPresent.

Mutable maps or sets can be turned into their immutable counterparts via the Clojure persistent! call. This allows working in a mutable space for convenience and performance then switching to an immutable pathway when necessary. Note: after persistent! one should never backdoor mutate map or set again as this will break the contract of immutability. Immutable data structures also support conversion to transient via transient.

Map keysets (.keySet) are full PersistentHashSets of keys.

Maps and sets support metadata but setting the metadata on mutable objects returns a new mutable object that shares the backing store leading to possible issues. Metadata is transferred to the persistent versions of the mutable/transient objects upon persistent!.

Very fast versions of union, difference and intersection are provided for maps and sets with the map version of union and difference requiring an extra argument, a java.util.BiFunction or an IFn taking 2 arguments to merge the left and right sides into the final map. These implementations of union, difference, and intersection are the fastest implementation of these operations we know of on the JVM.

Additionally a fast value update pathway is provided, enabling quickly updating all the values in a given map. Additionally, a new map primitive

  • mapmap - allows transforming a given map into a new map quickly by mapping across all the entries.

Unlike the standard Java objects, mutation-via-iterator is not supported.

Fast mutable and immutable associative data structures based on bitmap trie
hashmaps. Mutable pathways implement the `java.util.Map` or `Set` interfaces
including in-place update features such as compute or computeIfPresent.

Mutable maps or sets can be turned into their immutable counterparts via the
Clojure `persistent!` call. This allows working in a mutable space for
convenience and performance then switching to an immutable pathway when
necessary. Note: after `persistent!` one should never backdoor mutate map or
set again as this will break the contract of immutability.  Immutable
data structures also support conversion to transient via `transient`.

Map keysets (`.keySet`) are full `PersistentHashSet`s of keys.

Maps and sets support metadata but setting the metadata on mutable objects
returns a new mutable object that shares the backing store leading to possible
issues. Metadata is transferred to the persistent versions of the
mutable/transient objects upon `persistent!`.

Very fast versions of union, difference and intersection are provided for maps
and sets with the map version of union and difference requiring an extra
argument, a `java.util.BiFunction` or an `IFn` taking 2 arguments to merge the
left and right sides into the final map. These implementations of union,
difference, and intersection are the fastest implementation of these
operations we know of on the JVM.

Additionally a fast value update pathway is provided, enabling quickly
updating all the values in a given map. Additionally, a new map primitive
- [[mapmap]] - allows transforming a given map into a new map quickly by
mapping across all the entries.

Unlike the standard Java objects, mutation-via-iterator is not supported.
raw docstring

->bi-functionclj

(->bi-function cljfn)

Convert an object to a java.util.BiFunction. Object can either already be a bi-function or an IFn to be invoked with 2 arguments.

Convert an object to a java.util.BiFunction. Object can either already be a
bi-function or an IFn to be invoked with 2 arguments.
raw docstring

->collectionclj

(->collection item)

Ensure item is an implementation of java.util.Collection.

Ensure item is an implementation of java.util.Collection.
raw docstring

->functionclj

(->function cljfn)

Convert an object to a java Function. Object can either already be a Function or an IFn to be invoked.

Convert an object to a java Function. Object can either already be a
Function or an IFn to be invoked.
raw docstring

->random-accessclj

(->random-access item)

Ensure item is derived from java.util.List and java.util.RandomAccess and thus supports constant time random addressing.

Ensure item is derived from java.util.List and java.util.RandomAccess and
thus supports constant time random addressing.
raw docstring

->reducibleclj

(->reducible item)

Ensure item either implements IReduceInit or java.util.Collection. For arrays this will return an object that has a much more efficient reduction pathway than the base Clojure reducer.

Ensure item either implements IReduceInit or java.util.Collection.  For arrays
this will return an object that has a much more efficient reduction pathway
than the base Clojure reducer.
raw docstring

argsortclj

(argsort coll)
(argsort comp coll)

Sort a collection of data returning an array of indexes. The collection must be random access and the return value is an integer array of indexes which will read the input data in sorted order. Faster implementations are provided when the collection is an integer, long, or double array. See also reindex.

Note this sort is not nan, null aware. dtype-next provides a somewhat slower version in the argops namespace which will correctly handle null and nan values.

Sort a collection of data returning an array of indexes.  The collection must be
random access and the return value is an integer array of indexes which will read the
input data in sorted order.  Faster implementations are provided when the collection
is an integer, long, or double array.  See also [[reindex]].

Note this sort is not nan, null aware.  dtype-next provides a somewhat slower version
in the argops namespace which will correctly handle null and nan values.
raw docstring

array-listclj

(array-list)
(array-list data)

Create an implementation of java.util.ArrayList.

Create an implementation of java.util.ArrayList.
raw docstring

assocclj

(assoc m a b)
(assoc m a b c d)
(assoc m a b c d e f)
(assoc m a b c d e f g h)
(assoc m a b c d e f g h & args)

Drop in faster or equivalent replacement for clojure.core/assoc especially for small numbers of keyval pairs.

Drop in faster or equivalent replacement for clojure.core/assoc especially for
small numbers of keyval pairs.
raw docstring

assoc!clj

(assoc! obj k v)

assoc! that works on transient collections, implementations of java.util.Map and RandomAccess java.util.List implementations. Be sure to keep track of return value as some implementations return a different return value than the first argument.

assoc! that works on transient collections, implementations of java.util.Map and
RandomAccess java.util.List implementations.  Be sure to keep track of return value
as some implementations return a different return value than the first argument.
raw docstring

assoc-incljmacro

(assoc-in m ks v)

Assoc-in - more efficient replacement if ks is a known compile time constant or a vector. See the caveats in the README before using this exact function.

Assoc-in - more efficient replacement if ks is a known compile time constant
or a vector.  See the caveats in the README before using this exact function.
raw docstring

bi-functioncljmacro

(bi-function arg1 arg2 code)

Create an implementation of java.util.function.BiFunction

Create an implementation of java.util.function.BiFunction
raw docstring

clear!clj

(clear! map-or-coll)

Mutably clear a map, set, list or implementation of java.util.Collection.

Mutably clear a map, set, list or implementation of java.util.Collection.
raw docstring

clear-memoized-fn!clj

(clear-memoized-fn! memoize-fn)

Clear a memoized function backing store.

Clear a memoized function backing store.
raw docstring

compute!clj

(compute! m k bfn)

Compute a new value in a map derived from an existing value. bfn gets passed k, v where k may be nil. If the function returns nil the corresponding key is removed from the map.

See Map.compute

An example bfn for counting occurrences would be #(if % (inc (long %)) 1).

Compute a new value in a map derived from an existing value.  bfn gets passed k, v where k
may be nil.  If the function returns nil the corresponding key is removed from the map.

See [Map.compute](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#compute-K-java.util.function.BiFunction-)

An example `bfn` for counting occurrences would be `#(if % (inc (long %)) 1)`.
raw docstring

compute-if-absent!clj

(compute-if-absent! m k bfn)

Compute a value if absent from the map. Useful for memoize-type operations. Must use mutable maps. bfn gets passed k.

See map.computeIfAbsent

Compute a value if absent from the map.  Useful for memoize-type operations.  Must use
mutable maps.  bfn gets passed k.

See [map.computeIfAbsent](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#computeIfAbsent-K-java.util.function.Function-)
raw docstring

compute-if-present!clj

(compute-if-present! m k bfn)

Compute a new value if the value already exists and is non-nil in the hashmap. Must use mutable maps. bfn gets passed k, v where v is non-nil.

See Map.computeIfPresent

Compute a new value if the value already exists and is non-nil in the hashmap.  Must use
mutable maps.  bfn gets passed k, v where v is non-nil.

See [Map.computeIfPresent](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#computeIfPresent-K-java.util.function.BiFunction-)
raw docstring

concataclj

(concata)
(concata v1)
(concata v1 v2)
(concata v1 v2 & args)

non-lazily concat a set of items returning an object array. This always returns an object array an may return an empty array whereas concat may return nil.

non-lazily concat a set of items returning an object array.  This always returns an
object array an may return an empty array whereas concat may return nil.
raw docstring

concatvclj

(concatv)
(concatv v1)
(concatv v1 v2)
(concatv v1 v2 & args)

non-lazily concat a set of items returning a persistent vector.

non-lazily concat a set of items returning a persistent vector.  
raw docstring

conj!clj

(conj! obj val)

conj! that works on transient collections, implementations of java.util.Set and RandomAccess java.util.List implementations. Be sure to keep track of return value as some implementations return a different return value than the first argument.

conj! that works on transient collections, implementations of java.util.Set and
RandomAccess java.util.List implementations.  Be sure to keep track of return value
as some implementations return a different return value than the first argument.
raw docstring

constant-countclj

(constant-count data)

Constant time count. Returns nil if input doesn't have a constant time count.

Constant time count.  Returns nil if input doesn't have a constant time count.
raw docstring

constant-countable?clj

(constant-countable? data)

Return true if data has a constant time count.

Return true if data has a constant time count.
raw docstring

darangeclj

(darange end)
(darange start end)
(darange start end step)

Return a double array holding the values of the range. Useing ->collection to get an implementation of java.util.List that supports the normal Clojure interfaces.

Return a double array holding the values of the range.  Useing `->collection` to get
an implementation of java.util.List that supports the normal Clojure interfaces.
raw docstring

default-hash-providerclj

Default hash provider - currently set to the hybrid hash provider.

Default hash provider - currently set to the hybrid hash provider.
raw docstring

differenceclj

(difference map1 map2)

Take the difference of two maps (or sets) returning a new map. Return value is a map1 (or set1) without the keys present in map2.

Take the difference of two maps (or sets) returning a new map.  Return value is a map1
(or set1) without the keys present in map2.
raw docstring

double-arrayclj

(double-array data)

Create a double array from a number of some data

Create a double array from a number of some data
raw docstring

double-array-listclj

(double-array-list)
(double-array-list cap-or-data)

An array list that is as fast as java.util.ArrayList for add,get, etc but includes many accelerated operations such as fill and an accelerated addAll when the src data is an array list.

An array list that is as fast as java.util.ArrayList for add,get, etc but includes
many accelerated operations such as fill and an accelerated addAll when the src data
is an array list.
raw docstring

double-binary-operatorcljmacro

(double-binary-operator lvar rvar & code)

Create a binary operator that is specialized for double values. Useful to speed up operations such as sorting or summation.

Create a binary operator that is specialized for double values.  Useful to speed up
operations such as sorting or summation.
raw docstring

dropclj

(drop n coll)

Drop the first N items of the collection. If item is random access, the return value is random-access.

Drop the first N items of the collection.  If item is random access, the return
value is random-access.
raw docstring

drop-lastclj

(drop-last n coll)

Drop the last N values from a collection. IF the input is random access, the result will be random access.

Drop the last N values from a collection.  IF the input is random access,
the result will be random access.
raw docstring

drop-minclj

(drop-min n values)
(drop-min n comp values)

Drop the min n values of a collection. This is not an order-preserving operation.

Drop the min n values of a collection.  This is not an order-preserving operation.
raw docstring

empty-mapclj

Constant persistent empty map

Constant persistent empty map
raw docstring

empty-setclj

Constant persistent empty set

Constant persistent empty set
raw docstring

empty-vecclj

Constant persistent empty vec

Constant persistent empty vec
raw docstring

empty?clj

(empty? coll)

equal-hash-providerclj

Hash provider based on Object.hashCode and Object.equals - this is the same pathway that java.util.HashMap uses and is the overall the fastest hash provider. Hash-based data structures based on this hash provider will be faster to create and access but will not use the hasheq pathway. This is fine for integer keys, strings, keywords, and symbols, but differs for objects such as doubles, floats, and BigDecimals. This is the default hash provider.

Hash provider based on Object.hashCode and Object.equals - this is
the same pathway that `java.util.HashMap` uses and is the overall the fastest
hash provider.  Hash-based data structures based on this hash provider will be
faster to create and access but will not use the hasheq pathway. This is fine
for integer keys, strings, keywords, and symbols, but differs for objects such
as doubles, floats, and BigDecimals. This is the default hash provider.
raw docstring

equiv-hash-providerclj

Hash provider based on Clojure's hasheq and equiv pathways - the same algorithm that Clojure's persistent data structures use. This hash provider is somewhat (<2x) slower than the equal-hash-provider.

Hash provider based on Clojure's hasheq and equiv pathways - the
same algorithm that Clojure's persistent data structures use. This hash
provider is somewhat (<2x) slower than the [[equal-hash-provider]].
raw docstring

fast-reduceclj

(fast-reduce rfn iter)
(fast-reduce rfn init iter)

Version of reduce that is a bit faster for things that aren't sequences and do not implement IReduceInit.

Version of reduce that is a bit faster for things that aren't sequences and do not
implement IReduceInit.
raw docstring

filtervclj

(filterv pred coll)

Filter a collection into a vector.

Filter a collection into a vector.
raw docstring

firstclj

(first coll)

Get the first item of a collection.

Get the first item of a collection.
raw docstring

float-arrayclj

(float-array data)

Create a float array from a number of some data

Create a float array from a number of some data
raw docstring

frequenciesclj

(frequencies coll)

Faster implementation of clojure.core/frequencies.

Faster implementation of clojure.core/frequencies.
raw docstring

get-incljmacro

(get-in m ks)
(get-in m ks default-value)

get-in drop-in more efficient replacement if ks is a vector especially if ks is known at compile time.

get-in drop-in more efficient replacement if ks is a vector especially if ks
is known at compile time.
raw docstring

group-byclj

(group-by f coll)

Group items in collection by the grouping function f. Returns persistent map of keys to persistent vectors.

Group items in collection by the grouping function f.  Returns persistent map of
keys to persistent vectors.
raw docstring

group-by-reduceclj

(group-by-reduce key-fn reduce-fn coll)
(group-by-reduce key-fn reduce-fn finalize-fn coll)

Group by key. Apply the reduce-fn the existing value and on each successive value. finalize-fn is called during finalization with the sole argument of the existing value. If at any point result is reduced? group-by continues but further reductions for that specific value cease. In this case finalize-fn isn't called but the result is simply deref'd during finalization.

This type of reduction can be both faster and more importantly use less memory than a reduction of the forms:

(->> group-by map into)` or `(->> group-by mapmap)
ham-fisted.api> (group-by-reduce #(rem (unchecked-long %1) 7) + (range 100))
  {0 735, 1 750, 2 665, 3 679, 4 693, 5 707, 6 721}
ham-fisted.api> (group-by-reduce #(rem (unchecked-long %1) 7) max (shuffle (range 100)))
  {0 98, 1 99, 2 93, 3 94, 4 95, 5 96, 6 97}

ham-fisted.api> ;;Reduce to map of first value found
ham-fisted.api> (group-by-reduce #(rem (unchecked-long %1) 7) (fn [l r] l) (range 100))
{0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6}
ham-fisted.api> ;;Reduce to map of last value found
ham-fisted.api> (group-by-reduce #(rem (unchecked-long %1) 7) (fn [l r] r) (range 100))
{0 98, 1 99, 2 93, 3 94, 4 95, 5 96, 6 97}
Group by key. Apply the reduce-fn the existing value and on each successive value.
  finalize-fn is called during finalization with the sole argument of the existing value.
  If at any point result is reduced? group-by continues but further reductions for that
  specific value cease.  In this case finalize-fn isn't called but the result is simply
  deref'd during finalization.

  This type of reduction can be both faster and more importantly use
  less memory than a reduction of the forms:

  ```clojure
  (->> group-by map into)` or `(->> group-by mapmap)
  ```

```clojure
ham-fisted.api> (group-by-reduce #(rem (unchecked-long %1) 7) + (range 100))
  {0 735, 1 750, 2 665, 3 679, 4 693, 5 707, 6 721}
ham-fisted.api> (group-by-reduce #(rem (unchecked-long %1) 7) max (shuffle (range 100)))
  {0 98, 1 99, 2 93, 3 94, 4 95, 5 96, 6 97}

ham-fisted.api> ;;Reduce to map of first value found
ham-fisted.api> (group-by-reduce #(rem (unchecked-long %1) 7) (fn [l r] l) (range 100))
{0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6}
ham-fisted.api> ;;Reduce to map of last value found
ham-fisted.api> (group-by-reduce #(rem (unchecked-long %1) 7) (fn [l r] r) (range 100))
{0 98, 1 99, 2 93, 3 94, 4 95, 5 96, 6 97}
```
raw docstring

hash-mapclj

(hash-map)
(hash-map a b)
(hash-map a b c d)
(hash-map a b c d e f)
(hash-map a b c d e f g h)
(hash-map a b c d e f g h i j)
(hash-map a b c d e f g h i j k l)
(hash-map a b c d e f g h i j k l m n)
(hash-map a b c d e f g h i j k l m n o p)
(hash-map a b c d e f g h i j k l m n o p & args)

Drop-in replacement to Clojure's hash-map function.

Drop-in replacement to Clojure's hash-map function.
raw docstring

hybrid-hash-providerclj

Hash provider opportunistically using IHashEq pathway when provided else falling back to mixhash(obj.hashCode). For equality strictly uses Util.equiv as equality has not shown up to be a profiler bottleneck while generating mumur3 compatible hashes has in some cases (integers). This hash provider provides a middle ground offering more performance for simple datatypes but still using the more robust equiv pathways for more complex datatypes. This is currently the default hash provider for the library.

Hash provider opportunistically using IHashEq pathway when provided else
falling back to mixhash(obj.hashCode).  For equality strictly uses Util.equiv as equality
has not shown up to be a profiler bottleneck while generating mumur3 compatible hashes has in
some cases (integers).  This hash provider provides a middle ground offering more performance
for simple datatypes but still using the more robust equiv pathways for more complex datatypes.
This is currently the default hash provider for the library.
raw docstring

iarangeclj

(iarange end)
(iarange start end)
(iarange start end step)

Return an integer array holding the values of the range. Use ->collection to get a list implementation wrapping for generic access.

Return an integer array holding the values of the range.  Use `->collection` to get a
list implementation wrapping for generic access.
raw docstring

immut-listclj

(immut-list)
(immut-list data)

Create a persistent list. Object arrays will be treated as if this new object owns them.

Create a persistent list.  Object arrays will be treated as if this new object owns them.
raw docstring

immut-mapclj

(immut-map)
(immut-map data)
(immut-map options data)

Create an immutable map. This object supports conversion to a transient map via Clojure's transient function. Duplicate keys are treated as if by assoc.

If data is an object array it is treated as a flat key-value list which is distinctly different than how conj! treats object arrays. You have been warned.

If you know you will have consistently more key/val pairs than 8 you should just use (persistent! (mut-map data)) as that avoids the transition from an arraymap to a persistent hashmap.

Options:

  • :hash-provider - An implementation of BitmapTrieCommon$HashProvider. Defaults to the default-hash-provider.

Examples:

ham-fisted.api> (immut-map (obj-ary :a 1 :b 2 :c 3 :d 4))
{:a 1, :b 2, :c 3, :d 4}
ham-fisted.api> (type *1)
ham_fisted.PersistentArrayMap
ham-fisted.api> (immut-map (obj-ary :a 1 :b 2 :c 3 :d 4 :e 5))
{:d 4, :b 2, :c 3, :a 1, :e 5}
ham-fisted.api> (type *1)
ham_fisted.PersistentHashMap
ham-fisted.api> (immut-map [[:a 1][:b 2][:c 3][:d 4][:e 5]])
{:d 4, :b 2, :c 3, :a 1, :e 5}
ham-fisted.api> (type *1)
ham_fisted.PersistentHashMap
Create an immutable map.  This object supports conversion to a transient map via
  Clojure's `transient` function.  Duplicate keys are treated as if by assoc.

  If data is an object array it is treated as a flat key-value list which is distinctly
  different than how conj! treats object arrays.  You have been warned.

  If you know you will have consistently more key/val pairs than 8 you should just
  use `(persistent! (mut-map data))` as that avoids the transition from an arraymap
  to a persistent hashmap.

  Options:

  * `:hash-provider` - An implementation of `BitmapTrieCommon$HashProvider`.  Defaults to
  the [[default-hash-provider]].

  Examples:

  ```clojure
ham-fisted.api> (immut-map (obj-ary :a 1 :b 2 :c 3 :d 4))
{:a 1, :b 2, :c 3, :d 4}
ham-fisted.api> (type *1)
ham_fisted.PersistentArrayMap
ham-fisted.api> (immut-map (obj-ary :a 1 :b 2 :c 3 :d 4 :e 5))
{:d 4, :b 2, :c 3, :a 1, :e 5}
ham-fisted.api> (type *1)
ham_fisted.PersistentHashMap
ham-fisted.api> (immut-map [[:a 1][:b 2][:c 3][:d 4][:e 5]])
{:d 4, :b 2, :c 3, :a 1, :e 5}
ham-fisted.api> (type *1)
ham_fisted.PersistentHashMap
```
raw docstring

immut-setclj

(immut-set)
(immut-set data)
(immut-set options data)

Create an immutable hashset based on the bitmap trie. This object supports conversion to transients via transient.

Options:

  • :hash-provider - An implementation of BitmapTrieCommon$HashProvider. Defaults to the default-hash-provider.
Create an immutable hashset based on the bitmap trie.  This object supports conversion
to transients via `transient`.

Options:

* `:hash-provider` - An implementation of `BitmapTrieCommon$HashProvider`.  Defaults to
the [[default-hash-provider]].
raw docstring

in-fork-join-task?clj

(in-fork-join-task?)

True if you are currently running in a fork-join task

True if you are currently running in a fork-join task
raw docstring

int-arrayclj

(int-array data)

Create an integer array from a number of some data

Create an integer array from a number of some data
raw docstring

int-array-listclj

(int-array-list)
(int-array-list cap-or-data)

An array list that is as fast as java.util.ArrayList for add,get, etc but includes many accelerated operations such as fill and an accelerated addAll when the src data is an array list.

An array list that is as fast as java.util.ArrayList for add,get, etc but includes
many accelerated operations such as fill and an accelerated addAll when the src data
is an array list.
raw docstring

intersectionclj

(intersection s1 s2)

Intersect the keyspace of set1 and set2 returning a new set. Also works if s1 is a map and s2 is a set - the map is trimmed to the intersecting keyspace of s1 and s2.

Intersect the keyspace of set1 and set2 returning a new set.  Also works if s1 is a
map and s2 is a set - the map is trimmed to the intersecting keyspace of s1 and s2.
raw docstring

intoclj

(into container data)
(into container xform data)

Like clojure.core/into, but also designed to handle editable collections, transients, and base java.util.Map, List and Set containers.

Like clojure.core/into, but also designed to handle editable collections,
transients, and base java.util.Map, List and Set containers.
raw docstring

into-arrayclj

(into-array aseq)
(into-array ary-type aseq)
(into-array ary-type mapfn aseq)

Faster version of clojure.core/into-array.

Faster version of clojure.core/into-array.
raw docstring

iter-reduceclj

(iter-reduce rfn iter)
(iter-reduce rfn init iter)

Faster reduce for things like arraylists or hashmap entrysets that implement Iterable but not IReduceInit.

Faster reduce for things like arraylists or hashmap entrysets that implement Iterable
but not IReduceInit.
raw docstring

java-concurrent-hashmapclj

(java-concurrent-hashmap)
(java-concurrent-hashmap data)

Create a java concurrent hashmap which is still the fastest possible way to solve a few concurrent problems.

Create a java concurrent hashmap which is still the fastest possible way to solve a
few concurrent problems.
raw docstring

java-hashmapclj

(java-hashmap)
(java-hashmap data)

Create a java.util.HashMap. Duplicate keys are treated as if map was created by assoc.

Create a java.util.HashMap.  Duplicate keys are treated as if map was created by assoc.
raw docstring

java-hashsetclj

(java-hashset)
(java-hashset data)

Create a java hashset which is still the fastest possible way to solve a few problems.

Create a java hashset which is still the fastest possible way to solve a few problems.
raw docstring

larangeclj

(larange end)
(larange start end)
(larange start end step)

Return a long array holding values of the range. Use ->collection get a list implementation for generic access.

Return a long array holding values of the range.  Use `->collection` get a list
implementation for generic access.
raw docstring

lastclj

(last coll)

Get the last item in the collection. Constant time for random access lists.

Get the last item in the collection.  Constant time for
random access lists.
raw docstring

long-arrayclj

(long-array data)

Create a long array from a number of some data

Create a long array from a number of some data
raw docstring

long-array-listclj

(long-array-list)
(long-array-list cap-or-data)

An array list that is as fast as java.util.ArrayList for add,get, etc but includes many accelerated operations such as fill and an accelerated addAll when the src data is an array list.

An array list that is as fast as java.util.ArrayList for add,get, etc but includes
many accelerated operations such as fill and an accelerated addAll when the src data
is an array list.
raw docstring

long-binary-operatorcljmacro

(long-binary-operator lvar rvar & code)

Create a binary operator that is specialized for long values. Useful to speed up operations such as sorting or summation.

Create a binary operator that is specialized for long values.  Useful to speed up
operations such as sorting or summation.
raw docstring

make-comparatorcljmacro

(make-comparator lhsvar rhsvar code)

Make a java comparator.

Make a java comparator.
raw docstring

make-double-comparatorcljmacro

(make-double-comparator lhsvar rhsvar & code)

Make a comparator that gets passed two double arguments.

Make a comparator that gets passed two double arguments.
raw docstring

make-long-comparatorcljmacro

(make-long-comparator lhsvar rhsvar & code)

Make a comparator that gets passed two long arguments.

Make a comparator that gets passed two long arguments.
raw docstring

map-factoryclj

(map-factory keys)

Create a factory to quickly produce maps with a fixed set of keys but arbitrary values. This version takes a vector or sequence of keys and returns and IFn that takes a vector, object-array, or sequence of values. The most efficient pathway will be if values are already in an object array.

The factory produces PersistentHashMaps.

Create a factory to quickly produce maps with a fixed set of keys but arbitrary
values.  This version takes a vector or sequence of keys and returns and IFn that
takes a vector, object-array, or sequence of values.  The most efficient pathway will be
if values are already in an object array.

The factory produces PersistentHashMaps.
raw docstring

map-intersectionclj

(map-intersection bfn map1 map2)

Intersect the keyspace of map1 and map2 returning a new map. Each value is the result of bfn applied to the map1-value and map2-value, respectively. See documentation for map-union.

Clojure's merge functionality can be duplicate via:

(map-intersection (fn [lhs rhs] rhs) map1 map2)
Intersect the keyspace of map1 and map2 returning a new map.  Each value is the result
of bfn applied to the map1-value and map2-value, respectively.  See documentation for
[[map-union]].

Clojure's `merge` functionality can be duplicate via:

```clojure
(map-intersection (fn [lhs rhs] rhs) map1 map2)
```
raw docstring

map-keysetclj

(map-keyset m)

Return the keyset of the map. This may not be in the same order as (keys m) or (vals m). For hamf maps, this has the same ordering as (keys m). For both hamf and java hashmaps, the returned implementation of java.util.Set both more utility and better performance than (keys m).

Return the keyset of the map.  This may not be in the same order as (keys m) or (vals
m).  For hamf maps, this has the same ordering as (keys m).  For both hamf and java
hashmaps, the returned implementation of java.util.Set both more utility and better
performance than (keys m).
raw docstring

map-unionclj

(map-union bfn map1 map2)

Take the union of two maps returning a new map. bfn is a function that takes 2 arguments, map1-val and map2-val and returns a new value. Has fallback if map1 and map2 aren't backed by bitmap tries.

  • bfn - A function taking two arguments and returning one. + is a fine choice.
  • map1 - the lhs of the union.
  • map2 - the rhs of the union.

Returns a persistent map.

Take the union of two maps returning a new map.  bfn is a function that takes 2 arguments,
map1-val and map2-val and returns a new value.  Has fallback if map1 and map2 aren't backed
by bitmap tries.

 * `bfn` - A function taking two arguments and returning one.  `+` is a fine choice.
 * `map1` - the lhs of the union.
 * `map2` - the rhs of the union.

Returns a persistent map.
raw docstring

map-union-java-hashmapclj

(map-union-java-hashmap bfn lhs rhs)

Take the union of two maps returning a new map. See documentation for [map-union]. Returns a java.util.HashMap.

Take the union of two maps returning a new map.  See documentation for [map-union].
Returns a java.util.HashMap.
raw docstring

map-valuesclj

(map-values m)

Return the values collection of the map. This may not be in the same order as (keys m) or (vals m). For hamf hashmaps, this does have the same order as (vals m). For both hamf hashmaps and java hashmaps, this has better performance for reductions especially using fast-reduce than (vals m).

Return the values collection of the map.  This may not be in the same order as (keys m)
or (vals m).  For hamf hashmaps, this does have the same order as (vals m).  For both
hamf hashmaps and java hashmaps, this has better performance for reductions especially
using `fast-reduce` than (vals m).
raw docstring

mapmapclj

(mapmap map-fn src-map)

Clojure's missing piece. Map over the data in src-map, which must be a map or sequence of pairs, using map-fn. map-fn must return either a new key-value pair or nil. Then, remove nil pairs, and return a new map. If map-fn returns more than one pair with the same key later pair will overwrite the earlier pair.

Logically the same as:

(->> (map map-fn src-map) (remove nil?) (into {}))
Clojure's missing piece. Map over the data in src-map, which must be a map or
sequence of pairs, using map-fn. map-fn must return either a new key-value
pair or nil. Then, remove nil pairs, and return a new map. If map-fn returns
more than one pair with the same key later pair will overwrite the earlier
pair.

Logically the same as:

```clojure
(->> (map map-fn src-map) (remove nil?) (into {}))
```
raw docstring

mapvclj

(mapv map-fn coll)
(mapv map-fn c1 c2)
(mapv map-fn c1 c2 c3)
(mapv map-fn c1 c2 c3 & args)

Produce a persistent vector from a collection.

Produce a persistent vector from a collection.
raw docstring

meanclj

(mean coll)

Return the mean of the collection. Returns double/NaN for empty collections.

Return the mean of the collection.  Returns double/NaN for empty collections.
raw docstring

memoizeclj

(memoize memo-fn)
(memoize memo-fn
         {:keys [write-ttl-ms access-ttl-ms soft-values? weak-values? max-size
                 record-stats?]})

Efficient thread-safe version of clojure.core/memoize.

Also see clear-memoized-fn! to mutably clear the backing store.

Options.

  • :write-ttl-ms - Time that values should remain in the cache after write in milliseconds.
  • :access-ttl-ms - Time that values should remain in the cache after access in milliseconds.
  • :soft-values? - When true, the cache will store SoftReferences to the data.
  • :weak-values? - When true, the cache will store WeakReferences to the data.
  • :max-size - When set, the cache will behave like an LRU cache.
  • :record-stats? - When true, the LoadingCache will record access statistics. You can get those via the undocumented function memo-stats.
Efficient thread-safe version of clojure.core/memoize.

Also see [[clear-memoized-fn!]] to mutably clear the backing store.

Options.

* `:write-ttl-ms` - Time that values should remain in the cache after write in milliseconds.
* `:access-ttl-ms` - Time that values should remain in the cache after access in milliseconds.
* `:soft-values?` - When true, the cache will store [SoftReferences](https://docs.oracle.com/javase/7/docs/api/java/lang/ref/SoftReference.html) to the data.
* `:weak-values?` - When true, the cache will store [WeakReferences](https://docs.oracle.com/javase/7/docs/api/java/lang/ref/WeakReference.html) to the data.
* `:max-size` - When set, the cache will behave like an LRU cache.
* `:record-stats?` - When true, the LoadingCache will record access statistics.  You can
   get those via the undocumented function memo-stats.
raw docstring

mergeclj

(merge)
(merge m1)
(merge m1 m2)
(merge m1 m2 & args)

Merge 2 maps with the rhs values winning any intersecting keys. Uses map-union with BitmapTrieCommon/rhsWins.

Returns a new persistent map.

Merge 2 maps with the rhs values winning any intersecting keys.  Uses map-union
with `BitmapTrieCommon/rhsWins`.

Returns a new persistent map.
raw docstring

merge-withclj

(merge-with f)
(merge-with f m1)
(merge-with f m1 m2)
(merge-with f m1 m2 & args)

Merge (union) any number of maps using f as the merge operator. f gets passed two arguments, lhs-val and rhs-val and must return a new value.

Returns a new persistent map.

Merge (union) any number of maps using `f` as the merge operator.  `f` gets passed two
arguments, lhs-val and rhs-val and must return a new value.

Returns a new persistent map.
raw docstring

mut-listclj

(mut-list)
(mut-list data)

Create a mutable java list that is in-place convertible to a persistent list

Create a mutable java list that is in-place convertible to a persistent list
raw docstring

mut-mapclj

(mut-map)
(mut-map data)
(mut-map options data)

Create a mutable implementation of java.util.Map. This object efficiently implements ITransient map so you can use assoc! and persistent! on it but you can additionally use operations such as put!, remove!, compute-at! and compute-if-absent!. You can create a persistent hashmap via the clojure persistent! call.

If data is an object array it is treated as a flat key-value list which is distinctly different than how conj! treats object arrays. You have been warned.

Options:

  • :hash-provider - An implementation of BitmapTrieCommon$HashProvider. Defaults to the default-hash-provider.
Create a mutable implementation of java.util.Map.  This object efficiently implements
ITransient map so you can use assoc! and persistent! on it but you can additionally use
operations such as put!, remove!, compute-at! and compute-if-absent!.  You can create
a persistent hashmap via the clojure `persistent!` call.

If data is an object array it is treated as a flat key-value list which is distinctly
different than how conj! treats object arrays.  You have been warned.

Options:

* `:hash-provider` - An implementation of `BitmapTrieCommon$HashProvider`.  Defaults to
the [[default-hash-provider]].
raw docstring

mut-setclj

(mut-set)
(mut-set data)
(mut-set options data)

Create a mutable hashset based on the bitmap trie. You can create a persistent hashset via the clojure persistent! call.

Options:

  • :hash-provider - An implementation of BitmapTrieCommon$HashProvider. Defaults to the default-hash-provider.
Create a mutable hashset based on the bitmap trie. You can create a persistent hashset via
the clojure `persistent!` call.

Options:

* `:hash-provider` - An implementation of `BitmapTrieCommon$HashProvider`.  Defaults to
the [[default-hash-provider]].
raw docstring

obj-aryclj

(obj-ary)
(obj-ary v0)
(obj-ary v0 v1)
(obj-ary v0 v1 v2)
(obj-ary v0 v1 v2 v3)
(obj-ary v0 v1 v2 v3 v4)
(obj-ary v0 v1 v2 v3 v4 v5)
(obj-ary v0 v1 v2 v3 v4 v5 v6)
(obj-ary v0 v1 v2 v3 v4 v5 v6 v7)
(obj-ary v0 v1 v2 v3 v4 v5 v6 v7 v8)
(obj-ary v0 v1 v2 v3 v4 v5 v6 v7 v8 v9)
(obj-ary v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10)
(obj-ary v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11)
(obj-ary v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12)
(obj-ary v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13)
(obj-ary v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14)
(obj-ary v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 v15)

As quickly as possible, produce an object array from these inputs. Very fast for arities <= 6.

As quickly as possible, produce an object array from these inputs.  Very fast for arities
<= 6.
raw docstring

object-arrayclj

(object-array item)

Faster version of object-array for java collections and strings.

Faster version of object-array for java collections and strings.
raw docstring

object-array-listclj

(object-array-list)
(object-array-list cap-or-data)

An array list that is as fast as java.util.ArrayList for add,get, etc but includes many accelerated operations such as fill and an accelerated addAll when the src data is an object array based list.

An array list that is as fast as java.util.ArrayList for add,get, etc but includes
many accelerated operations such as fill and an accelerated addAll when the src data
is an object array based list.
raw docstring

pgroupsclj

(pgroups n-elems body-fn)
(pgroups n-elems body-fn options)

Run y groups across n-elems. Y is common pool parallelism.

body-fn gets passed two longs, startidx and endidx.

Returns a sequence of the results of body-fn applied to each group of indexes.

Options:

  • :pgroup-min - when provided n-elems must be more than this value for the computation to be parallelized.
  • :batch-size - max batch size. Defaults to 64000.
Run y groups across n-elems.   Y is common pool parallelism.

body-fn gets passed two longs, startidx and endidx.

Returns a sequence of the results of body-fn applied to each group of indexes.

Options:

* `:pgroup-min` - when provided n-elems must be more than this value for the computation
  to be parallelized.
* `:batch-size` - max batch size.  Defaults to 64000.
raw docstring

pmapclj

(pmap map-fn & sequences)

pmap using the commonPool. This is useful for interacting with other primitives, namely pgroups which are also based on this pool. This is a change from Clojure's base pmap in that it uses the ForkJoinPool/commonPool for parallelism as opposed to the agent pool - this makes it compose with pgroups and dtype-next's parallelism system.

pmap using the commonPool.  This is useful for interacting with other primitives, namely
[[pgroups]] which are also based on this pool.  This is a change from Clojure's base
pmap in that it uses the ForkJoinPool/commonPool for parallelism as opposed to the
agent pool - this makes it compose with pgroups and dtype-next's parallelism system.
raw docstring

rangeclj

(range)
(range end)
(range start end)
(range start end step)

When given arguments returns a range that implements random access java list interfaces so nth, reverse and friends are efficient.

When given arguments returns a range that implements random access java list
interfaces so nth, reverse and friends are efficient.
raw docstring

rcompclj

A reverse comparator that sorts in descending order

A reverse comparator that sorts in descending order
raw docstring

reduce-put-mapclj

(reduce-put-map m data)

Perform a reduction to put values as if by assoc into a mutable map.

Perform a reduction to put values as if by assoc into a mutable map.
raw docstring

reindexclj

(reindex coll indexes)

Permut coll by the given indexes. Result is random-access and the same length as the index collection. Indexes are expected to be in the range of [0->count(coll)).

Permut coll by the given indexes.  Result is random-access and the same length as
the index collection.  Indexes are expected to be in the range of [0->count(coll)).
raw docstring

repeatclj

(repeat v)
(repeat n v)

When called with no arguments, produce an infinite sequence of v. When called with 2 arguments, produce a random access list that produces v at each index.

When called with no arguments, produce an infinite sequence of v.
When called with 2 arguments, produce a random access list that produces v at each
index.
raw docstring

reverseclj

(reverse coll)

Reverse a collection or sequence. Constant time reverse is provided for any random access list.

Reverse a collection or sequence.  Constant time reverse is provided
for any random access list.
raw docstring

shuffleclj

(shuffle coll)
(shuffle coll opts)

shuffle values returning random access container.

Options:

  • :seed - If instance of java.util.Random, use this. If integer, use as seed. If not provided a new instance of java.util.Random is created.
shuffle values returning random access container.

Options:

* `:seed` - If instance of java.util.Random, use this.  If integer, use as seed.
If not provided a new instance of java.util.Random is created.
raw docstring

sortclj

(sort coll)
(sort comp coll)

Exact replica of clojure.core/sort but instead of wrapping the final object array in a seq which loses the fact the result is countable and random access. Faster implementations are provided when the input is an integer, long, or double array.

Exact replica of clojure.core/sort but instead of wrapping the final object array in a seq
which loses the fact the result is countable and random access.  Faster implementations
are provided when the input is an integer, long, or double array.
raw docstring

sort-byclj

(sort-by keyfn coll)
(sort-by keyfn comp coll)

Sort a collection by keyfn. Typehinting the return value of keyfn will somewhat increase the speed of the sort :-).

Sort a collection by keyfn.  Typehinting the return value of keyfn will somewhat increase
the speed of the sort :-).
raw docstring

sortaclj

(sorta coll)
(sorta comp coll)

Sort returning an object array.

Sort returning an object array.
raw docstring

spliceclj

(splice v1 idx v2)

Splice v2 into v1 at idx. Returns a persistent vector.

Splice v2 into v1 at idx.  Returns a persistent vector.
raw docstring

subvecclj

(subvec m sidx)
(subvec m sidx eidx)

More general version of subvec. Works for any java list implementation including persistent vectors and any array.

More general version of subvec.  Works for any java list implementation
including persistent vectors and any array.
raw docstring

sumclj

(sum coll)

Fast simple double summation. Does not do any summation compensation but does parallelize the summation for random access containers leading to some additional numeric stability.

Fast simple double summation.  Does not do any summation compensation but does
parallelize the summation for random access containers leading to some additional
numeric stability.
raw docstring

takeclj

(take n coll)

Take the first N values from a collection. If the input is random access, the result will be random access.

Take the first N values from a collection.  If the input is
random access, the result will be random access.
raw docstring

take-lastclj

(take-last n coll)

Take the last N values of the collection. If the input is random-access, the result will be random-access.

Take the last N values of the collection.  If the input is random-access,
the result will be random-access.
raw docstring

take-minclj

(take-min n values)
(take-min n comp values)

Take the min n values of a collection. This is not an order-preserving operation.

Take the min n values of a collection.  This is not an order-preserving operation.
raw docstring

type-single-arg-ifnclj

(type-single-arg-ifn ifn)

Categorize the return type of a single argument ifn. May be :float64, :int64, or :object.

Categorize the return type of a single argument ifn.  May be :float64, :int64, or :object.
raw docstring

unionclj

(union s1 s2)

Union of two sets or two maps. When two maps are provided the right hand side wins in the case of an intersection.

Result is either a set or a map, depending on if s1 is a set or map.

Union of two sets or two maps.  When two maps are provided the right hand side
wins in the case of an intersection.

Result is either a set or a map, depending on if s1 is a set or map.
raw docstring

union-reduce-java-hashmapclj

(union-reduce-java-hashmap bfn maps)
(union-reduce-java-hashmap bfn maps options)

Do an efficient union of many maps into a single java.util.HashMap.

Do an efficient union of many maps into a single java.util.HashMap.
raw docstring

union-reduce-mapsclj

(union-reduce-maps bfn maps)

Do an efficient union reduction across many maps using bfn to update values. See documentation for [map-union]. If any of the input maps are not implementations provided by this library this falls backs to (reduce (partial union-maps bfn) maps).

Do an efficient union reduction across many maps using bfn to update values.  See
documentation for [map-union].  If any of the input maps are not implementations provided
by this library this falls backs to `(reduce (partial union-maps bfn) maps)`.
raw docstring

updateclj

(update m k f)
(update m k f x)
(update m k f x y)
(update m k f x y z)
(update m k f x y z & more)

Version of update that produces maps from this library.

Version of update that produces maps from this library.
raw docstring

update-incljmacro

(update-in m ks f & args)

An attempt at a slightly more efficient version of update-in.

See the caveats in the readme - measure carefully before using this.

An attempt at a slightly more efficient version of update-in.

See the caveats in the readme - measure carefully before using this.
raw docstring

update-valuesclj

(update-values map bfn)

Immutably update all values in the map returning a new map. bfn takes 2 arguments, k,v and returns a new v. Returns new persistent map. If passed a vector, k is the index and v is the value. Will return a new vector. else map is assumed to be convertible to a sequence and this pathway works the same as map-indexed.

Immutably update all values in the map returning a new map.  bfn takes 2 arguments,
k,v and returns a new v. Returns new persistent map.
If passed a vector, k is the index and v is the value.  Will return a new vector.
else map is assumed to be convertible to a sequence and this pathway works the same
as map-indexed.
raw docstring

upmapclj

(upmap map-fn & sequences)

Unordered pmap using the commonPool. This is useful for interacting with other primitives, namely pgroups which are also based on this pool. Like pmap this uses the commonPool so it composes with this api's pmap, pgroups, and dtype-next's parallelism primitives but it does not impose an ordering constraint on the results and thus may be significantly faster in some cases.

Unordered pmap using the commonPool.  This is useful for interacting with other primitives,
namely [[pgroups]] which are also based on this pool.
Like pmap this uses the commonPool so it composes with this api's pmap, pgroups, and
dtype-next's parallelism primitives *but* it does not impose an ordering constraint on the
results and thus may be significantly faster in some cases.
raw docstring

vecclj

(vec)
(vec data)

Produce a persistent vector. Optimized pathways exist for object arrays and java List implementations.

Produce a persistent vector.  Optimized pathways exist for object arrays and
java List implementations.
raw docstring

vectorclj

(vector)
(vector a)
(vector a b)
(vector a b c)
(vector a b c d)
(vector a b c d e)
(vector a b c d e f)
(vector a b c d e f g)
(vector a b c d e f g h)
(vector a b c d e f g h i)
(vector a b c d e f g h i j)
(vector a b c d e f g h i j k)
(vector a b c d e f g h i j k & args)

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

× close