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

->collectionclj

(->collection item)

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

Ensure item is an implementation of java.util.Collection.
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

add-all!clj

(add-all! l1 l2)

Add all items from l2 to l1. l1 is expected to be a java.util.List implementation. Returns l1.

Add all items from l2 to l1.  l1 is expected to be a java.util.List implementation.
Returns l1.
raw docstring

apply-concatclj

(apply-concat args)

Faster lazy noncaching version of (apply concat)

Faster lazy noncaching version of (apply concat)
raw docstring

apply-concatvclj

(apply-concatv data)

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.

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]].
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

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

(binary-search coll v)
(binary-search coll v comp)

Binary search. Coll must be a sorted random access container. comp must be an implementation of java.lang.Comparator. If you know your container's type, such as a double array, then comp should be a fastutil DoubleComparator.

The most efficient method will be to convert coll to random access using ->random-access, so for a pure double array it is slightly better to call ->random-access outside this function before the function call.

This search defaults to the slower java.util.Collections search using clojure's built in compare - reason being that that allows you to search for a double number in a vector of only longs. If you want an accelerated search you can explicitly pass in a nil comparator but you need to make sure that you are searching for the rough datatype in the data - e.g. long in a byte array or a double in a double for float array. Searching for doubles in integer arrays with an accelerated search will probably result in confusing results.

ham-fisted.api> (def data (->random-access (double-array (range 10))))
#'ham-fisted.api/data
ham-fisted.api> (binary-search data 0)
0
ham-fisted.api> (binary-search data -1)
0
ham-fisted.api> (binary-search data 1)
1
ham-fisted.api> (binary-search data 1.1)
2
ham-fisted.api> (binary-search data 10)
10
ham-fisted.api> (binary-search data 11)
10
ham-fisted.api> ;;be wary of datatype conversions in typed containers
ham-fisted.api> (def data (->random-access (int-array (range 10))))
#'ham-fisted.api/data
ham-fisted.api> (binary-search data 1)
1
ham-fisted.api> (binary-search data 1.1)
  2
ham-fisted.api> ;;accelerated search - flattens input to container datatype
ham-fisted.api> (binary-search data 1.1 nil)
1
Binary search.  Coll must be a sorted random access container.
  comp must be an implementation of java.lang.Comparator.  If you know your container's
  type, such as a double array, then comp should be a fastutil DoubleComparator.


  The most efficient method will be to convert coll to random access using
  ->random-access, so for a pure double array it is slightly better to call
  ->random-access outside this function before the function call.

  This search defaults to the slower java.util.Collections search using
  clojure's built in `compare` - reason being that that allows you to search
  for a double number in a vector of only longs.  If you want an accelerated search
  you can explicitly pass in a nil comparator *but* you need to make sure that
  you are searching for the rough datatype in the data - e.g. long in a byte array
  or a double in a double for float array.  Searching for doubles in integer arrays
  with an accelerated search will probably result in confusing results.

```clojure
ham-fisted.api> (def data (->random-access (double-array (range 10))))
#'ham-fisted.api/data
ham-fisted.api> (binary-search data 0)
0
ham-fisted.api> (binary-search data -1)
0
ham-fisted.api> (binary-search data 1)
1
ham-fisted.api> (binary-search data 1.1)
2
ham-fisted.api> (binary-search data 10)
10
ham-fisted.api> (binary-search data 11)
10
ham-fisted.api> ;;be wary of datatype conversions in typed containers
ham-fisted.api> (def data (->random-access (int-array (range 10))))
#'ham-fisted.api/data
ham-fisted.api> (binary-search data 1)
1
ham-fisted.api> (binary-search data 1.1)
  2
ham-fisted.api> ;;accelerated search - flattens input to container datatype
ham-fisted.api> (binary-search data 1.1 nil)
1
```
raw docstring

boolean-arrayclj

(boolean-array)
(boolean-array data)

boolean-array-listclj

(boolean-array-list)
(boolean-array-list data)

byte-arrayclj

(byte-array)
(byte-array data)

byte-array-listclj

(byte-array-list)
(byte-array-list data)

char-arrayclj

(char-array)
(char-array data)

char-array-listclj

(char-array-list)
(char-array-list data)

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! memoized-fn)

Clear a memoized function backing store.

Clear a memoized function backing store.
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

custom-counted-ireducecljmacro

(custom-counted-ireduce n-elems rfn acc & code)

Custom implementation of IReduceInit and nothing else. This can be the most efficient way to pass data to other interfaces. Also see custom-ireduce if the object does not need to be counted and see reduced-> for implementation helper.

Custom implementation of IReduceInit and nothing else.  This can be the most efficient
way to pass data to other interfaces.  Also see custom-ireduce if the object
does not need to be counted and see [[reduced->]] for implementation helper.
raw docstring

custom-ireducecljmacro

(custom-ireduce rfn acc & code)

Custom implementation of IReduceInit and nothing else. This can be the most efficient way to pass data to other interfaces. Also see custom-counted-ireduce if the object should also implement ICounted. See reduced-> for implementation helper.

Custom implementation of IReduceInit and nothing else.  This can be the most efficient
way to pass data to other interfaces.  Also see [[custom-counted-ireduce]] if the object
should also implement ICounted.  See [[reduced->]] for implementation helper.
raw docstring

darangeclj

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

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

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

dbl-ary-clsclj


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

dnthcljmacro

(dnth obj idx)

nth operation returning a primitive double. Efficient when obj is a double array.

nth operation returning a primitive double.  Efficient when obj is a double array.
raw docstring

double-arraycljmacro

(double-array)
(double-array data)

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

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)
(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

dveccljmacro

(dvec)
(dvec data)

Create a persistent-vector-compatible list backed by a double array.

Create a persistent-vector-compatible list backed by a double array.
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)

evict-memoized-callclj

(evict-memoized-call memo-fn fn-args)

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-arraycljmacro

(float-array)
(float-array data)

float-array-listclj

(float-array-list)
(float-array-list data)

fnthcljmacro

(fnth obj idx)

nth operation returning a primitive float. Efficient when obj is a float array.

nth operation returning a primitive float.  Efficient when obj is a float array.
raw docstring

freq-reducerclj

(freq-reducer)
(freq-reducer options)

Return a hamf parallel reducer that performs a frequencies operation.

Return a hamf parallel reducer that performs a frequencies operation.
raw docstring

frequenciesclj

(frequencies coll)
(frequencies options coll)

Faster implementation of clojure.core/frequencies.

Faster implementation of clojure.core/frequencies.
raw docstring

fveccljmacro

(fvec)
(fvec data)

Create a persistent-vector-compatible list backed by a float array.

Create a persistent-vector-compatible list backed by a float array.
raw docstring

group-byclj

(group-by f coll)
(group-by f options coll)

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

Options are same as group-by-reduce but this reductions defaults to an ordered reduction.

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

Options are same as [[group-by-reduce]] but this reductions defaults to an
ordered reduction.
raw docstring

group-by-consumerclj

(group-by-consumer key-fn reducer coll)
(group-by-consumer key-fn reducer options coll)

Perform a group-by-reduce passing in a reducer. Same options as group-by-reduce - This uses a slightly different pathway - computeIfAbsent - in order to preserve order. In this case the return value of the reduce fn is ignored. This allows things like the linked hash map to preserve initial order of keys. It map also be slightly more efficient because the map itself does not need to check the return value of rfn - something that the .compute primitive does need to do.

Options:

  • :skip-finalize? - skip finalization step.
Perform a group-by-reduce passing in a reducer.  Same options as group-by-reduce -
This uses a slightly different pathway - computeIfAbsent - in order to preserve order.
In this case the return value of the reduce fn is ignored.  This allows things like
the linked hash map to preserve initial order of keys.  It map also be slightly
more efficient because the map itself does not need to check the return value
of rfn - something that the `.compute` primitive *does* need to do.

Options:

* `:skip-finalize?` - skip finalization step.
raw docstring

group-by-reduceclj

(group-by-reduce key-fn init-val-fn rfn merge-fn coll)
(group-by-reduce key-fn init-val-fn rfn merge-fn options coll)

Group by key. Apply the reduce-fn with the new value an the return of init-val-fn. Merged maps due to multithreading will be merged with merge-fn in a similar way of [[preduce]].

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)

Options (which are passed to [[preduce]]):

  • :map-fn Function which takes no arguments and must return an instance of java.util.Map that supports computeIfAbsent. Some examples:
    • (constantly (java.util.concurrent.ConcurrentHashMap. ...)) Very fast update especially in the case where the keyspace is large.
    • mut-map - Fast merge, fast update, in-place immutable conversion via persistent!.
    • java-hashmap - fast merge, fast update, just a simple java.util.HashMap-based reduction.
    • #(LinkedHashMap.) - When used with options {:ordered? true} the result keys will be in order and the result values will be reduced in order.
Group by key. Apply the reduce-fn with the new value an the return of init-val-fn.
  Merged maps due to multithreading will be merged with merge-fn in a similar way
  of [[preduce]].

  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)
```

  Options (which are passed to [[preduce]]):

  * `:map-fn` Function which takes no arguments and must return an instance of
    java.util.Map that supports `computeIfAbsent`.  Some examples:
    - `(constantly (java.util.concurrent.ConcurrentHashMap. ...))`  Very fast update
       especially in the case where the keyspace is large.
    - `mut-map` - Fast merge, fast update, in-place immutable conversion via `persistent!`.
    - `java-hashmap` - fast merge, fast update, just a simple java.util.HashMap-based reduction.
    - `#(LinkedHashMap.)` - When used with options {:ordered? true} the result keys will be
       in order *and* the result values will be reduced in order.
raw docstring

group-by-reducerclj

(group-by-reducer key-fn reducer coll)
(group-by-reducer key-fn reducer options coll)

Perform a group-by-reduce passing in a reducer. Same options as group-by-reduce.

Options:

  • :skip-finalize? - skip finalization step.
Perform a group-by-reduce passing in a reducer.  Same options as group-by-reduce.

Options:

* `:skip-finalize?` - skip finalization step.
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

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.

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.

  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 a hash table. 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 a hash table.  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

inc-consumerclj

(inc-consumer)
(inc-consumer init-value)

Return a consumer that simply increments a long. See java/ham_fisted/Consumers.java for definition.

Return a consumer that simply increments a long.  See java/ham_fisted/Consumers.java for definition.
raw docstring

inc-consumer-reducerclj

A hamf reducer that works with inc-consumers

A hamf reducer that works with inc-consumers
raw docstring

int-arraycljmacro

(int-array)
(int-array data)

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

intersect-setsclj

(intersect-sets sets)

Given a sequence of sets, efficiently perform the intersection of them. This algorithm is usually faster and has a more stable runtime than (reduce clojure.set/intersection sets) which degrades depending on the order of the sets and the pairwise intersection of the initial sets.

Given a sequence of sets, efficiently perform the intersection of them.  This algorithm is usually faster and has a more stable
runtime than (reduce clojure.set/intersection sets) which degrades depending on the order of the sets and the pairwise
intersection of the initial sets.
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

inthcljmacro

(inth obj idx)

nth operation returning a primitive int. Efficient when obj is an int array.

nth operation returning a primitive int.  Efficient when obj is an int array.
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

iveccljmacro

(ivec)
(ivec data)

Create a persistent-vector-compatible list backed by an int array.

Create a persistent-vector-compatible list backed by an int array.
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)
(java-hashmap xform data)
(java-hashmap xform options 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

java-linked-hashmapclj

(java-linked-hashmap)
(java-linked-hashmap data)

Linked hash maps perform identically or very nearly so to java.util.HashMaps but they retain the order of insertion and modification.

Linked hash maps perform identically or very nearly so to java.util.HashMaps
but they retain the order of insertion and modification.
raw docstring

keysclj

(keys m)

Return the keys of a map. This version allows parallel reduction operations on the returned sequence.

Return the keys of a map.  This version allows parallel reduction operations on
the returned sequence.
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

linked-hashmapclj

(linked-hashmap)
(linked-hashmap data)

Linked hash map using clojure's equiv pathways. At this time the node link order reflects insertion order. Modification and access do not affect the node link order.

Linked hash map using clojure's equiv pathways.  At this time the node link order reflects
insertion order.  Modification and access do not affect the node link order.
raw docstring

lnthcljmacro

(lnth obj idx)

nth operation returning a primitive long. Efficient when obj is a long array.

nth operation returning a primitive long.  Efficient when obj is a long array.
raw docstring

long-arraycljmacro

(long-array)
(long-array data)

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

lveccljmacro

(lvec)
(lvec data)

Create a persistent-vector-compatible list backed by a long array.

Create a persistent-vector-compatible list backed by a long array.
raw docstring

make-map-entrycljmacro

(make-map-entry k-code v-code)

Create a dynamic implementation of clojure's IMapEntry class.

Create a dynamic implementation of clojure's IMapEntry class.
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-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 if input is a persistent map else if map1 is a mutable map map1 is returned with overlapping entries merged. In this way you can pass in a normal java hashmap, a linked java hashmap, or a persistent map and get back a result that matches the input.

If map1 and map2 are the same returns map1.

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 if input is a persistent map else if map1 is a mutable map
map1 is returned with overlapping entries merged.  In this way you can pass in a
normal java hashmap, a linked java hashmap, or a persistent map and get back a result that
matches the input.

If map1 and map2 are the same returns map1.
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

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:

(into {} (comp (map map-fn) (remove nil?)) 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:

```clojure
(into {} (comp (map map-fn) (remove nil?)) src-map)
```
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)
(mean options coll)

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

Return the mean of the collection.  Returns double/NaN for empty collections.
See options for [[sum]].
raw docstring

memoizeclj

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

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

Also see clear-memoized-fn! evict-memoized-call and memoize-cache-as-map to mutably clear the backing store, manually evict a value, and get a java.util.Map view of the cache backing store.

ham-fisted.api> (def m (memoize (fn [& args] (println "fn called - " args) args)
                                {:write-ttl-ms 1000 :eviction-fn (fn [args rv cause]
                                                                   (println "evicted - " args rv cause))}))
#'ham-fisted.api/m
ham-fisted.api> (m 3)
fn called -  (3)
(3)
ham-fisted.api> (m 4)
fn called -  (4)
(4)evicted -  [3] (3) :expired
ham-fisted.api> (dotimes [idx 4] (do (m 3) (evict-memoized-call m [3])))
fn called -  (3)
fn called -  (3)
fn called -  (3)
fn called -  (3)
nil
ham-fisted.api> (dotimes [idx 4] (do (m 3) #_(evict-memoized-call m [3])))
fn called -  (3)
nil

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.
  • :eviction-fn - Function that receives 3 arguments, [args v cause], when a value is evicted. Causes the keywords:collected :expired :explicit :replaced and :size`. See caffeine documentation for cause definitions.
Efficient thread-safe version of clojure.core/memoize.

  Also see [[clear-memoized-fn!]] [[evict-memoized-call]] and [[memoize-cache-as-map]] to
  mutably clear the backing store, manually evict a value, and get a java.util.Map view of
  the cache backing store.


```clojure
ham-fisted.api> (def m (memoize (fn [& args] (println "fn called - " args) args)
                                {:write-ttl-ms 1000 :eviction-fn (fn [args rv cause]
                                                                   (println "evicted - " args rv cause))}))
#'ham-fisted.api/m
ham-fisted.api> (m 3)
fn called -  (3)
(3)
ham-fisted.api> (m 4)
fn called -  (4)
(4)evicted -  [3] (3) :expired
ham-fisted.api> (dotimes [idx 4] (do (m 3) (evict-memoized-call m [3])))
fn called -  (3)
fn called -  (3)
fn called -  (3)
fn called -  (3)
nil
ham-fisted.api> (dotimes [idx 4] (do (m 3) #_(evict-memoized-call m [3])))
fn called -  (3)
nil
```

  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.
  * `:eviction-fn - Function that receives 3 arguments, [args v cause], when a value is
     evicted.  Causes the keywords `:collected :expired :explicit :replaced and :size`.  See
     [caffeine documentation](https://www.javadoc.io/static/com.github.ben-manes.caffeine/caffeine/2.9.3/com/github/benmanes/caffeine/cache/RemovalCause.html) for cause definitions.
raw docstring

memoize-cache-as-mapclj

(memoize-cache-as-map memoized-fn)

Return the memoize backing store as an implementation of java.util.Map.

Return the memoize backing store as an implementation of java.util.Map.
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

mmax-idxclj

(mmax-idx f data)

Like mmin-key but returns the max index. F should be a function from obj->long.

Like [[mmin-key]] but returns the max index.  F should be a function from obj->long.
raw docstring

mmax-keyclj

(mmax-key f data)

Faster and nil-safe version of #(apply max-key %1 %2)

Faster and nil-safe version of #(apply max-key %1 %2)
raw docstring

mmin-idxclj

(mmin-idx f data)

Like mmin-key but returns the min index. F should be a function from obj->long.

Like [[mmin-key]] but returns the min index.  F should be a function from obj->long.
raw docstring

mmin-keyclj

(mmin-key f data)

Faster and nil-safe version of #(apply min-key %1 %2)

Faster and nil-safe version of #(apply min-key %1 %2)
raw docstring

modeclj

(mode data)

Return the most common occurance in the data.

Return the most common occurance in the data.
raw docstring

mut-hashtable-mapclj

(mut-hashtable-map)
(mut-hashtable-map data)
(mut-hashtable-map xform data)
(mut-hashtable-map xform 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 the various members of the java.util.Map interface such as put, compute, computeIfAbsent, replaceAll and merge.

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.

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
the various members of the java.util.Map interface such as put, compute, computeIfAbsent,
replaceAll and merge.

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.
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-long-hashtable-mapclj

(mut-long-hashtable-map)
(mut-long-hashtable-map data)
(mut-long-hashtable-map xform data)
(mut-long-hashtable-map xform 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 the various members of the java.util.Map interface such as put, compute, computeIfAbsent, replaceAll and merge.

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.

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
the various members of the java.util.Map interface such as put, compute, computeIfAbsent,
replaceAll and merge.

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.
raw docstring

mut-long-mapclj

(mut-long-map)
(mut-long-map data)
(mut-long-map xform data)
(mut-long-map xform options data)

Create a mutable implementation of java.util.Map specialized to long keys. This object efficiently implements ITransient map so you can use assoc! and persistent! on it but you can additionally use the various members of the java.util.Map interface such as put, compute, computeIfAbsent, replaceAll and merge. Attempting to store any non-numeric value will result in an exception.

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.

Create a mutable implementation of java.util.Map specialized to long keys.  This object
efficiently implements ITransient map so you can use assoc! and persistent! on it but you can additionally use
the various members of the java.util.Map interface such as put, compute, computeIfAbsent,
replaceAll and merge.  Attempting to store any non-numeric value will result in an exception.

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.
raw docstring

mut-mapclj

(mut-map)
(mut-map data)
(mut-map xform data)
(mut-map xform 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 the various members of the java.util.Map interface such as put, compute, computeIfAbsent, replaceAll and merge.

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.

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
the various members of the java.util.Map interface such as put, compute, computeIfAbsent,
replaceAll and merge.

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.
raw docstring

mut-map-rfclj

(mut-map-rf cons-fn)
(mut-map-rf cons-fn finalize-fn)

mut-map-union!clj

(mut-map-union! merge-bifn l r)

Very fast union that may simply update lhs and return it. Both lhs and rhs must be mutable maps. See docs for map-union.

Very fast union that may simply update lhs and return it.  Both lhs and rhs *must* be
mutable maps.  See docs for [[map-union]].
raw docstring

mut-setclj

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

Create a mutable hashset based on the hashtable. 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 hashtable. 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

mutable-map?clj

(mutable-map? m)

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 <= 16.

As quickly as possible, produce an object array from these inputs.  Very fast for arities
<= 16.
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

oveccljmacro

(ovec)
(ovec data)

Return an immutable persistent vector like object backed by a single object array.

Return an immutable persistent vector like object backed by a single object array.
raw docstring

persistent!clj

(persistent! v)

If object is an ITransientCollection, call clojure.core/persistent!. Else return collection.

If object is an ITransientCollection, call clojure.core/persistent!.  Else return
collection.
raw docstring

pgroupsclj

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

Run y index 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.

Before using this primitive please see if ham-fisted.reduce/preduce will work.

You must wrap this in something that realizes the results if you need the parallelization to finish by a particular point in the program - (dorun (hamf/pgroups ...)).

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 index 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.

Before using this primitive please see if [[ham-fisted.reduce/preduce]] will work.

You *must* wrap this in something that realizes the results if you need the parallelization
to finish by a particular point in the program - `(dorun (hamf/pgroups ...))`.

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.

Before using this primitive please see if ham-fisted.reduce/preduce will work.

Is guaranteed to not trigger the need for shutdown-agents.

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.

  Before using this primitive please see if [[ham-fisted.reduce/preduce]] will work.

Is guaranteed to *not* trigger the need for `shutdown-agents`.
raw docstring

pmap-optsclj

(pmap-opts opts map-fn & sequences)

pmap but takes an extra option map as the first argument. This is useful if you, for instance, want to control exactly the parallel options arguments such as :n-lookahead. See docs for ham-fisted.reduce/options->parallel-options.

[[pmap]] but takes an extra option map as the *first* argument.  This is useful if you,
 for instance, want to control exactly the parallel options arguments such as
`:n-lookahead`.  See docs for [[ham-fisted.reduce/options->parallel-options]].
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

reduced->cljmacro

(reduced-> rfn acc & data)

Helper macro to implement reduce chains checking for if the accumulator is reduced before calling the next expression in data.

(defrecord YMC [year-month ^long count]
  clojure.lang.IReduceInit
  (reduce [this rfn init]
    (let [init (reduced-> rfn init
                   (clojure.lang.MapEntry/create :year-month year-month)
                   (clojure.lang.MapEntry/create :count count))]
      (if (and __extmap (not (reduced? init)))
        (reduce rfn init __extmap)
        init))))
Helper macro to implement reduce chains checking for if the accumulator
  is reduced before calling the next expression in data.

```clojure
(defrecord YMC [year-month ^long count]
  clojure.lang.IReduceInit
  (reduce [this rfn init]
    (let [init (reduced-> rfn init
                   (clojure.lang.MapEntry/create :year-month year-month)
                   (clojure.lang.MapEntry/create :count count))]
      (if (and __extmap (not (reduced? init)))
        (reduce rfn init __extmap)
        init))))
```
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

restclj

(rest coll)

Version of rest that does uses subvec if collection is random access. This preserves the ability to reduce in parallel over the collection.

Version of rest that does uses subvec if collection is random access.  This preserves the
ability to reduce in parallel over the collection.
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

short-arrayclj

(short-array)
(short-array data)

short-array-listclj

(short-array-list)
(short-array-list data)

shuffleclj

(shuffle coll)
(shuffle coll opts)

shuffle values returning random access container. If you are calling this repeatedly on the same collection you should call ->random-access on the collection before you start as shuffle internally only works on random access collections.

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.  If you are calling this repeatedly
 on the same collection you should call [[->random-access]] on the collection *before*
 you start as shuffle internally only works on random access collections.

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.

The default comparison is nan-last meaning null-last if the input is an undefined container and nan-last if the input is a double or float specific container.

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.

The default comparison is nan-last meaning null-last if the input is an undefined
container and nan-last if the input is a double or float specific container.
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)
(sum options coll)

Very stable high performance summation. Uses both threading and kahans compensated summation.

Options:

  • nan-strategy - defaults to :remove. Options are :keep, :remove and :exception.
Very stable high performance summation.  Uses both threading and kahans compensated
summation.

Options:

* `nan-strategy` - defaults to `:remove`.  Options are `:keep`, `:remove` and
`:exception`.
raw docstring

sum-fastclj

(sum-fast coll)

Fast simple double summation. Does not do any nan checking or summation compensation.

Fast simple double summation.  Does not do any nan checking or summation
compensation.
raw docstring

sum-stable-nelemsclj

(sum-stable-nelems coll)
(sum-stable-nelems options coll)

Stable sum returning map of {:sum :n-elems}. See options for sum.

Stable sum returning map of {:sum :n-elems}. See options for [[sum]].
raw docstring

takeclj

(take n)
(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)
(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

transientclj

(transient v)

transient-map-rfclj

(transient-map-rf cons-fn)
(transient-map-rf cons-fn finalize-fn)

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 - same as merge.

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 - same as merge.

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

union-reduce-mapsclj

(union-reduce-maps bfn maps)

Do an efficient union reduction across many maps using bfn to update values. If the first map is mutable the union is done mutably into the first map and it is returned.

Do an efficient union reduction across many maps using bfn to update values.
If the first map is mutable the union is done mutably into the first map and it is
returned.
raw docstring

update-valsclj

(update-vals data f)

update-valuesclj

(update-values map bfn)

Immutably (or mutably) update all values in the map returning a new map. bfn takes 2 arguments, k,v and returns a new v. Returning nil removes the key from the map. When passed a vector the keys are indexes and no nil-removal is done.

Immutably (or mutably) update all values in the map returning a new map.
bfn takes 2 arguments, k,v and returns a new v. Returning nil removes the key from the map.
When passed a vector the keys are indexes and no nil-removal is done.
raw docstring

upgroupsclj

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

Run y index 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.

Before using this primitive please see if ham-fisted.reduce/preduce will work.

You must wrap this in something that realizes the results if you need the parallelization to finish by a particular point in the program - (dorun (hamf/upgroups ...)).

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 index 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.

Before using this primitive please see if [[ham-fisted.reduce/preduce]] will work.

You *must* wrap this in something that realizes the results if you need the parallelization
to finish by a particular point in the program - `(dorun (hamf/upgroups ...))`.

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

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.

Before using this primitive please see if ham-fisted.reduce/preduce will work.

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.

Before using this primitive please see if [[ham-fisted.reduce/preduce]] will work.

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

valsclj

(vals m)

Return the values of a map. This version allows parallel reduction operations on the returned sequence. Returned sequence is in same order as (keys m).

Return the values of a map.  This version allows parallel reduction operations on
the returned sequence.  Returned sequence is in same order as `(keys m)`.
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)

wrap-arrayclj

(wrap-array ary)

Wrap an array with an implementation of IMutList

Wrap an array with an implementation of IMutList
raw docstring

wrap-array-growableclj

(wrap-array-growable ary)
(wrap-array-growable ary ptr)

Wrap an array with an implementation of IMutList that supports add and addAllReducible. 'ptr is the numeric put ptr, defaults to the array length. Pass in zero for a preallocated but empty growable wrapper.

Wrap an array with an implementation of IMutList that supports add and addAllReducible.
'ptr is the numeric put ptr, defaults to the array length.  Pass in zero for a preallocated
but empty growable wrapper.
raw docstring

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

× close