Liking cljdoc? Tell your friends :D

criterium.array

Typed array collections using primitive arrays to avoid boxing.

Provides wrappers around primitive arrays (double-array, long-array) that can be used for efficient sample storage during benchmarking. Three types are provided for the three metric types:

  • DoubleArray for :quantitative metrics
  • LongArray for :event metrics
  • ObjectArray for :nominal metrics
Typed array collections using primitive arrays to avoid boxing.

Provides wrappers around primitive arrays (double-array, long-array)
that can be used for efficient sample storage during benchmarking.
Three types are provided for the three metric types:
  - DoubleArray for :quantitative metrics
  - LongArray for :event metrics
  - ObjectArray for :nominal metrics
raw docstring

->double-arrayclj

(->double-array arr)

Creates a DoubleArray from a primitive double array. Use (double-array coll) to convert a collection to a primitive array first.

Creates a DoubleArray from a primitive double array.
Use (double-array coll) to convert a collection to a primitive array first.
sourceraw docstring

->long-arrayclj

(->long-array arr)

Creates a LongArray from a primitive long array. Use (long-array coll) to convert a collection to a primitive array first.

Creates a LongArray from a primitive long array.
Use (long-array coll) to convert a collection to a primitive array first.
sourceraw docstring

->object-arrayclj

(->object-array arr)

Creates an ObjectArray from an object array. Use (object-array coll) to convert a collection to an object array first.

Creates an ObjectArray from an object array.
Use (object-array coll) to convert a collection to an object array first.
sourceraw docstring

array-opsclj

source

array=clj

(array= arr expected)

Returns true if typed array elements equal the expected sequence. Compares element-by-element using == for doubles/longs, = for objects.

Returns true if typed array elements equal the expected sequence.
Compares element-by-element using == for doubles/longs, = for objects.
sourceraw docstring

capacityclj

Returns the maximum capacity of a resizable array.

Returns the maximum capacity of a resizable array.
sourceraw docstring

dany?clj

(dany? arr pred)

Returns true if any element satisfies the predicate. pred must be (fn [^double x] ...) returning truthy/falsy. Works with DoubleArray and LongArray.

Returns true if any element satisfies the predicate.
pred must be (fn [^double x] ...) returning truthy/falsy.
Works with DoubleArray and LongArray.
sourceraw docstring

dfoldclj

(dfold arr f init)

Reduces over elements with an object-returning function, receiving primitive doubles. Works with both DoubleArray and LongArray (longs are converted to doubles). f must be (fn [acc ^double val] ...) - receives primitive double, returns Object. Use this when accumulating into a collection.

Reduces over elements with an object-returning function, receiving primitive doubles.
Works with both DoubleArray and LongArray (longs are converted to doubles).
f must be (fn [acc ^double val] ...) - receives primitive double, returns Object.
Use this when accumulating into a collection.
sourceraw docstring

dfold-skipclj

(dfold-skip arr skip-idx f init)

Fold over elements skipping the element at skip-idx, returning Object. Used for jackknife resampling when accumulating into a collection. f must be (fn [acc ^double val] ...) - receives primitive double, returns Object. Works with DoubleArray and LongArray.

Fold over elements skipping the element at skip-idx, returning Object.
Used for jackknife resampling when accumulating into a collection.
f must be (fn [acc ^double val] ...) - receives primitive double, returns Object.
Works with DoubleArray and LongArray.
sourceraw docstring

dmapclj

(dmap arr f)

Maps f over elements, returning a new DoubleArray. f must be (fn ^double [^double x] ...). Works with DoubleArray and LongArray.

Maps f over elements, returning a new DoubleArray.
f must be (fn ^double [^double x] ...).
Works with DoubleArray and LongArray.
sourceraw docstring

dmap-indexedclj

(dmap-indexed arr f)

Maps f over elements with index, returning a new DoubleArray. f must be (fn ^double [^long idx ^double x] ...). Works with DoubleArray and LongArray.

Maps f over elements with index, returning a new DoubleArray.
f must be (fn ^double [^long idx ^double x] ...).
Works with DoubleArray and LongArray.
sourceraw docstring

double-array?clj

(double-array? x)

Returns true if x is a DoubleArray.

Returns true if x is a DoubleArray.
sourceraw docstring

doubles-fillclj

(doubles-fill n v)

Creates a primitive double array of length n filled with value v.

Creates a primitive double array of length n filled with value v.
sourceraw docstring

elem-typeclj

(elem-type arr)

Returns the element type keyword: :double, :long, or :object.

Returns the element type keyword: :double, :long, or :object.
sourceraw docstring

fill!cljmacro

(fill! arr value)

Fills an array with the specified value. Dispatches to the appropriate primitive fill method at compile time based on the array's type hint. Returns arr for chaining.

Fills an array with the specified value.
Dispatches to the appropriate primitive fill method at compile time
based on the array's type hint.
Returns arr for chaining.
sourceraw docstring

filter-indicesclj

(filter-indices arr exclude-set)

Returns a new typed array containing only elements at indices NOT in exclude-set. Returns the same type as input: DoubleArray returns DoubleArray, LongArray returns LongArray. exclude-set is a set of long indices to exclude.

Returns a new typed array containing only elements at indices NOT in exclude-set.
Returns the same type as input: DoubleArray returns DoubleArray, LongArray returns LongArray.
exclude-set is a set of long indices to exclude.
sourceraw docstring

first-doubleclj

(first-double arr)

Returns the first element from a DoubleArray as a primitive double.

Returns the first element from a DoubleArray as a primitive double.
sourceraw docstring

first-elementclj

(first-element arr)

Returns the first element from a typed array. Dispatches based on runtime array type for cases where the type cannot be statically determined.

Returns the first element from a typed array.
Dispatches based on runtime array type for cases where the type
cannot be statically determined.
sourceraw docstring

first-longclj

(first-long arr)

Returns the first element from a LongArray as a primitive long.

Returns the first element from a LongArray as a primitive long.
sourceraw docstring

first-objectclj

(first-object arr)

Returns the first element from an ObjectArray.

Returns the first element from an ObjectArray.
sourceraw docstring

foldclj

(fold arr f init)

Reduces over the elements with function f and initial value init. f is called as (f acc elem) for each element. This is the generic version that boxes primitive values.

Reduces over the elements with function f and initial value init.
f is called as (f acc elem) for each element.
This is the generic version that boxes primitive values.
sourceraw docstring

fold-doubleclj

(fold-double arr f init)

Reduces over elements with a primitive double function. Works with both DoubleArray and LongArray (longs are converted to doubles). f must be (fn ^double [^double acc ^double val] ...). Returns a primitive double.

Reduces over elements with a primitive double function.
Works with both DoubleArray and LongArray (longs are converted to doubles).
f must be (fn ^double [^double acc ^double val] ...).
Returns a primitive double.
sourceraw docstring

fold-double-skipclj

(fold-double-skip arr skip-idx f init)

Fold over elements skipping the element at skip-idx. Used for jackknife resampling. f must be (fn ^double [^double acc ^double val] ...). Works with DoubleArray and LongArray. Returns a primitive double.

Fold over elements skipping the element at skip-idx.
Used for jackknife resampling.
f must be (fn ^double [^double acc ^double val] ...).
Works with DoubleArray and LongArray.
Returns a primitive double.
sourceraw docstring

fold-longclj

(fold-long arr f init)

Reduces over long elements with a primitive long function. f must be (fn ^long [^long acc ^long val] ...). Returns a primitive long.

Reduces over long elements with a primitive long function.
f must be (fn ^long [^long acc ^long val] ...).
Returns a primitive long.
sourceraw docstring

get-atclj

(get-at arr index)

Returns the element at index. Works with DoubleArray, LongArray, and ObjectArray.

Returns the element at index.
Works with DoubleArray, LongArray, and ObjectArray.
sourceraw docstring

get-doubleclj

(get-double arr index)

Returns the value at index as a primitive double.

Returns the value at index as a primitive double.
sourceraw docstring

get-longclj

(get-long arr index)

Returns the value at index as a primitive long.

Returns the value at index as a primitive long.
sourceraw docstring

indexed-dfoldclj

(indexed-dfold arr f init)

Fold over elements with index, accumulating and returning Object. f must be (fn [acc ^long idx ^double val] ...). Uses .invokePrim to avoid boxing on the index and value arguments. Works with both DoubleArray and LongArray.

Fold over elements with index, accumulating and returning Object.
f must be (fn [acc ^long idx ^double val] ...).
Uses .invokePrim to avoid boxing on the index and value arguments.
Works with both DoubleArray and LongArray.
sourceraw docstring

indexed-fold-doubleclj

(indexed-fold-double arr f init)

Fold over elements with index, accumulating and returning primitive double. f must be (fn ^double [^double acc ^long idx ^double val] ...). Uses .invokePrim to avoid boxing. Works with both DoubleArray and LongArray.

Fold over elements with index, accumulating and returning primitive double.
f must be (fn ^double [^double acc ^long idx ^double val] ...).
Uses .invokePrim to avoid boxing.
Works with both DoubleArray and LongArray.
sourceraw docstring

lany?clj

(lany? arr pred)

Returns true if any element satisfies the predicate. pred must be (fn [^long x] ...) returning truthy/falsy. Works only with LongArray.

Returns true if any element satisfies the predicate.
pred must be (fn [^long x] ...) returning truthy/falsy.
Works only with LongArray.
sourceraw docstring

last-doubleclj

(last-double arr)

Returns the last element from a DoubleArray as a primitive double.

Returns the last element from a DoubleArray as a primitive double.
sourceraw docstring

last-longclj

(last-long arr)

Returns the last element from a LongArray as a primitive long.

Returns the last element from a LongArray as a primitive long.
sourceraw docstring

last-objectclj

(last-object arr)

Returns the last element from an ObjectArray.

Returns the last element from an ObjectArray.
sourceraw docstring

lengthclj

(length arr)

Returns the number of elements in the array.

Returns the number of elements in the array.
sourceraw docstring

lfoldclj

(lfold arr f init)

Reduces over long elements with an object-returning function. f must be (fn [acc ^long val] ...) - receives primitive long, returns Object. Use this when accumulating into a collection from LongArray.

Reduces over long elements with an object-returning function.
f must be (fn [acc ^long val] ...) - receives primitive long, returns Object.
Use this when accumulating into a collection from LongArray.
sourceraw docstring

lmapclj

(lmap arr f)

Maps f over elements, returning a new LongArray. f must be (fn ^long [^long x] ...). Works only with LongArray.

Maps f over elements, returning a new LongArray.
f must be (fn ^long [^long x] ...).
Works only with LongArray.
sourceraw docstring

lmap-indexedclj

(lmap-indexed arr f)

Maps f over elements with index, returning a new LongArray. f must be (fn ^long [^long idx ^long x] ...). Works only with LongArray.

Maps f over elements with index, returning a new LongArray.
f must be (fn ^long [^long idx ^long x] ...).
Works only with LongArray.
sourceraw docstring

long-array?clj

(long-array? x)

Returns true if x is a LongArray.

Returns true if x is a LongArray.
sourceraw docstring

longs-fillclj

(longs-fill n v)

Creates a primitive long array of length n filled with value v.

Creates a primitive long array of length n filled with value v.
sourceraw docstring

make-doublesclj

(make-doubles a)
(make-doubles a b)
(make-doubles a b c)
(make-doubles a b c d)

Creates a primitive double array with 1-4 explicit values. Avoids ISeq iteration overhead of (double-array [...]).

Creates a primitive double array with 1-4 explicit values.
Avoids ISeq iteration overhead of `(double-array [...])`.
sourceraw docstring

make-longsclj

(make-longs a)
(make-longs a b)
(make-longs a b c)
(make-longs a b c d)

Creates a primitive long array with 1-4 explicit values. Avoids ISeq iteration overhead of (long-array [...]).

Creates a primitive long array with 1-4 explicit values.
Avoids ISeq iteration overhead of `(long-array [...])`.
sourceraw docstring

object-array?clj

(object-array? x)

Returns true if x is an ObjectArray.

Returns true if x is an ObjectArray.
sourceraw docstring

resizable-double-arrayclj

Creates a ResizableDoubleArray with given capacity. With one argument, creates array with size equal to capacity. With two arguments, creates array with given capacity and initial size. The initial size must be between 0 and capacity (inclusive).

Creates a ResizableDoubleArray with given capacity.
With one argument, creates array with size equal to capacity.
With two arguments, creates array with given capacity and initial size.
The initial size must be between 0 and capacity (inclusive).
sourceraw docstring

resizable-double-array?clj

Returns true if x is a ResizableDoubleArray.

Returns true if x is a ResizableDoubleArray.
sourceraw docstring

resizable-long-arrayclj

Creates a ResizableLongArray with given capacity. With one argument, creates array with size equal to capacity. With two arguments, creates array with given capacity and initial size. The initial size must be between 0 and capacity (inclusive).

Creates a ResizableLongArray with given capacity.
With one argument, creates array with size equal to capacity.
With two arguments, creates array with given capacity and initial size.
The initial size must be between 0 and capacity (inclusive).
sourceraw docstring

resizable-long-array?clj

Returns true if x is a ResizableLongArray.

Returns true if x is a ResizableLongArray.
sourceraw docstring

resizable-object-arrayclj

Creates a ResizableObjectArray with given capacity. With one argument, creates array with size equal to capacity. With two arguments, creates array with given capacity and initial size. The initial size must be between 0 and capacity (inclusive).

Creates a ResizableObjectArray with given capacity.
With one argument, creates array with size equal to capacity.
With two arguments, creates array with given capacity and initial size.
The initial size must be between 0 and capacity (inclusive).
sourceraw docstring

resizable-object-array?clj

Returns true if x is a ResizableObjectArray.

Returns true if x is a ResizableObjectArray.
sourceraw docstring

resize!clj

Resizes a resizable array to a new size. The new size must be between 0 and capacity (inclusive). Returns the new size.

Resizes a resizable array to a new size.
The new size must be between 0 and capacity (inclusive).
Returns the new size.
sourceraw docstring

set-at!cljmacro

(set-at! arr index value)

Returns the element at index. Works with DoubleArray, LongArray, and ObjectArray.

Returns the element at index.
Works with DoubleArray, LongArray, and ObjectArray.
sourceraw docstring

sortedclj

(sorted arr)

Returns a new sorted DoubleArray. Uses Java's Arrays.sort for efficient primitive sorting. LongArray is converted to DoubleArray during sorting.

Returns a new sorted DoubleArray.
Uses Java's Arrays.sort for efficient primitive sorting.
LongArray is converted to DoubleArray during sorting.
sourceraw docstring

sumclj

(sum arr)

Returns the sum of elements. For DoubleArray returns double, for LongArray returns long.

Returns the sum of elements.
For DoubleArray returns double, for LongArray returns long.
sourceraw docstring

sum-doubleclj

(sum-double arr)

Returns the sum of elements as a primitive double. Works with DoubleArray.

Returns the sum of elements as a primitive double.
Works with DoubleArray.
sourceraw docstring

sum-longclj

(sum-long arr)

Returns the sum of elements as a primitive long. Only works with LongArray.

Returns the sum of elements as a primitive long.
Only works with LongArray.
sourceraw docstring

to-fixedclj

Converts a resizable array to a fixed array of the same element type. Creates a new array containing only the active elements (0 to size-1). ResizableDoubleArray -> DoubleArray, ResizableLongArray -> LongArray, ResizableObjectArray -> ObjectArray.

Converts a resizable array to a fixed array of the same element type.
Creates a new array containing only the active elements (0 to size-1).
ResizableDoubleArray -> DoubleArray, ResizableLongArray -> LongArray,
ResizableObjectArray -> ObjectArray.
sourceraw docstring

typed-array?clj

(typed-array? x)

Returns true if x is a typed array (DoubleArray, LongArray, or ObjectArray).

Returns true if x is a typed array (DoubleArray, LongArray, or ObjectArray).
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

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