Host arrays. Arrays do not follow classic collection API in order to enable their performance.

Array is an abstraction for host array, a low level host specific container of objects. Depending on the use case, you can work directly with array, utilizing array manager, or wrap it into a reducible collection.

Simplest way is to wrap array into the ArrayColl by calling adapt. In cases where this is not possible or you may want better performance, you have following options:

  • aXXX functions provide inline variants that get rid of boxing and also reflection, if you provide a proper type signature, or choose function with right suffix.

  • If you do not know the type of array but have array’s manager, use it. It is fast but there will be some boxing.

Primary

aclone

Available since version 1.0 (alias of clojure.core/aclone)

not referred automatically

Usage:
  • (aclone array)

Type signature:
  • (AnyArray) → AnyArray

Returns a clone of the host array. Works on arrays of known types.

See also: dunaj.state/clone

acount

Available since version 1.0 (alias of clojure.core/alength)

not referred automatically

Usage:
  • (acount array)

Type signature:
  • (AnyArray) → Int

Returns the length of the host array. Works on arrays of all types.

See also: aget, dunaj.coll/count

adapt

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (adapt arr)

  • (adapt am arr)

  • (adapt arr begin end)

  • (adapt am arr begin end)

Type signatures:
  • (AnyArray) → (U ArrayColl BatchableArrayColl)

  • (ArrayManager ⨯ AnyArray) → (U ArrayColl BatchableArrayColl)

  • (AnyArray ⨯ Int ⨯ Int) → (U ArrayColl BatchableArrayColl)

  • (ArrayManager ⨯ AnyArray ⨯ Int ⨯ Int) → (U ArrayColl BatchableArrayColl)

Returns an immutable collection which wraps part of a given arr-ay. Does not copy array. Assumes user has control over the array and its contents won’t change.

aget

Available since version 1.0 (alias of clojure.core/aget)

not referred automatically

Usage:
  • (aget array idx)

  • (aget array idx & idxs)

Type signatures:
  • (AnyArray ⨯ Int) → Any

  • (AnyArray ⨯ Int ⨯ (Va Int)) → Any

Returns the value at the index/indices. Works on host arrays of all types.

amap

Available since version 1.0 (alias of clojure.core/amap)

not referred automatically

MACRO (amap a idx ret expr)

Maps an expression expr across an array a, using an index named idx, and return value named ret, initialized to a clone of a, then setting each item of ret to the evaluation of expr, returning the new array ret.

areduce

Available since version 1.0 (alias of clojure.core/areduce)

not referred automatically

MACRO (areduce a idx ret init expr)

Reduces an expression across an array a, using an index named idx, and return value named ret, initialized to init, setting ret to the evaluation of expr at each step, returning ret.

array

Available since version 1.0 (alias of clojure.core/into-array)

not referred automatically

Usage:
  • (array aseq)

  • (array type aseq)

Type signatures:
  • (IRed) → AnyArray

  • (Class+ ⨯ IRed) → AnyArray

Returns an array with components set to the values in aseq. The array’s component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type.

See also: make-array, to-array

array-item-type

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (array-item-type arr)

Type signature:
  • (AnyArray) → Class+

Returns array’s item type.

array-manager

Available since version 1.0 (view source)

Usage:
  • (array-manager item-type)

Type signature:
  • ((U nil Class+ Type)) → (Maybe ArrayManager)

Returns array manager for a given type, or nil if given type is not supported.

See also: array-manager-from

array-manager-from

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (array-manager-from arr)

Type signature:
  • (AnyArray) → (Maybe ArrayManager)

Returns array manager from an existing array arr, or nil if given array is not supported.

See also: array-manager

array?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (array? x)

Type signature:
  • (Any) → Boolean+

Returns true if x is an array, false otherwise.

aset!

Available since version 1.0 (alias of clojure.core/aset)

not referred automatically

Usage:
  • (aset! array idx val)

  • (aset! array idx idx2 & idxv)

Type signatures:
  • (AnyArray ⨯ Integer+ ⨯ Any) → Any

  • (AnyArray ⨯ Integer+ ⨯ Integer+ ⨯ (Va Any)) → Any

Sets the value val at the index/indices. Works on host arrays of reference types. Returns val.

See also: object-array?, aget

make-array

Available since version 1.0 (alias of clojure.core/make-array)

not referred automatically

Usage:
  • (make-array type len)

  • (make-array type dim & more-dims)

Type signatures:
  • (Class+ ⨯ Integer+) → AnyArray

  • (Class+ ⨯ Integer+ ⨯ (Va Integer+)) → AnyArray

Returns a nil/zero-filled host array of specified type Class+ and either len length, or given dimensions.

See also: to-array, array

object-array

Available since version 1.0 (alias of clojure.core/object-array)

not referred automatically

Usage:
  • (object-array size-or-seq)

Type signature:
  • ((U Integer+ IRed)) → (Array java.lang.Object)

Creates an array of objects.

object-array?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (object-array? x)

Type signature: Predicate

Returns true if x is an object array, false otherwise.

See also: object-array

to-array

Available since version 1.0 (alias of clojure.core/to-array)

not referred automatically

Usage:
  • (to-array coll)

Type signature:
  • (IRed) → AnyArray

Returns host object array and fills it with contents of coll, which must be an immutable collection, array or a host collection.

to-array-2d

Available since version 1.0 (alias of clojure.core/to-array-2d)

not referred automatically

Usage:
  • (to-array-2d coll)

Type signature:
  • (IRed) → AnyArray

Returns host object array and fills it with object arrays created from items of coll. The items in coll must be immutable collections, arrays or a host collections.

See also: to-array

Primitives

Functions specific to host primitive types.

aset-boolean!

Available since version 1.0 (alias of clojure.core/aset-boolean)

not referred automatically

Usage:
  • (aset-boolean! array idx val)

  • (aset-boolean! array idx idx2 & idxv)

Type signatures:
  • (AnyArray ⨯ Integer+ ⨯ Any) → Any

  • (AnyArray ⨯ Integer+ ⨯ Integer+ ⨯ (Va Any)) → Any

Sets the value val at the index/indices. Works on arrays of boolean. Returns val.

See also: boolean-array?, aget

aset-byte!

Available since version 1.0 (alias of clojure.core/aset-byte)

not referred automatically

Usage:
  • (aset-byte! array idx val)

  • (aset-byte! array idx idx2 & idxv)

Type signatures:
  • (AnyArray ⨯ Integer+ ⨯ Any) → Any

  • (AnyArray ⨯ Integer+ ⨯ Integer+ ⨯ (Va Any)) → Any

Sets the value val at the index/indices. Works on arrays of byte. Returns val.

See also: byte-array?, aget

aset-char!

Available since version 1.0 (alias of clojure.core/aset-char)

not referred automatically

Usage:
  • (aset-char! array idx val)

  • (aset-char! array idx idx2 & idxv)

Type signatures:
  • (AnyArray ⨯ Integer+ ⨯ Any) → Any

  • (AnyArray ⨯ Integer+ ⨯ Integer+ ⨯ (Va Any)) → Any

Sets the value val at the index/indices. Works on arrays of char. Returns val.

See also: char-array?, aget

aset-double!

Available since version 1.0 (alias of clojure.core/aset-double)

not referred automatically

Usage:
  • (aset-double! array idx val)

  • (aset-double! array idx idx2 & idxv)

Type signatures:
  • (AnyArray ⨯ Integer+ ⨯ Any) → Any

  • (AnyArray ⨯ Integer+ ⨯ Integer+ ⨯ (Va Any)) → Any

Sets the value val at the index/indices. Works on arrays of double. Returns val.

See also: double-array?, aget

aset-float!

Available since version 1.0 (alias of clojure.core/aset-float)

not referred automatically

Usage:
  • (aset-float! array idx val)

  • (aset-float! array idx idx2 & idxv)

Type signatures:
  • (AnyArray ⨯ Integer+ ⨯ Any) → Any

  • (AnyArray ⨯ Integer+ ⨯ Integer+ ⨯ (Va Any)) → Any

Sets the value val at the index/indices. Works on arrays of float. Returns val.

See also: float-array?, aget

aset-int!

Available since version 1.0 (alias of clojure.core/aset-int)

not referred automatically

Usage:
  • (aset-int! array idx val)

  • (aset-int! array idx idx2 & idxv)

Type signatures:
  • (AnyArray ⨯ Integer+ ⨯ Any) → Any

  • (AnyArray ⨯ Integer+ ⨯ Integer+ ⨯ (Va Any)) → Any

Sets the value val at the index/indices. Works on arrays of int. Returns val.

See also: int-array?, aget

aset-long!

Available since version 1.0 (alias of clojure.core/aset-long)

not referred automatically

Usage:
  • (aset-long! array idx val)

  • (aset-long! array idx idx2 & idxv)

Type signatures:
  • (AnyArray ⨯ Integer+ ⨯ Any) → Any

  • (AnyArray ⨯ Integer+ ⨯ Integer+ ⨯ (Va Any)) → Any

Sets the value val at the index/indices. Works on arrays of long. Returns val.

See also: long-array?, aget

aset-short!

Available since version 1.0 (alias of clojure.core/aset-short)

not referred automatically

Usage:
  • (aset-short! array idx val)

  • (aset-short! array idx idx2 & idxv)

Type signatures:
  • (AnyArray ⨯ Integer+ ⨯ Any) → Any

  • (AnyArray ⨯ Integer+ ⨯ Integer+ ⨯ (Va Any)) → Any

Sets the value val at the index/indices. Works on arrays of short. Returns val.

See also: short-array?, aget

boolean-array

Available since version 1.0 (alias of clojure.core/boolean-array)

not referred automatically

Usage:
  • (boolean-array size-or-seq)

  • (boolean-array size init-val-or-seq)

Type signatures:
  • ((U Integer+ IRed)) → (Array Boolean)

  • (Integer+ ⨯ Any) → (Array Boolean)

Creates an array of booleans.

boolean-array?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (boolean-array? x)

Type signature: Predicate

Returns true if x is a boolean array, false otherwise.

See also: booleans, boolean-array

booleans

Available since version 1.0 (alias of clojure.core/booleans)

not referred automatically

Usage:
  • (booleans xs)

Type signature:
  • (Any) → (Array Boolean)

Cast to boolean[]

byte-array

Available since version 1.0 (alias of clojure.core/byte-array)

not referred automatically

Usage:
  • (byte-array size-or-seq)

  • (byte-array size init-val-or-seq)

Type signatures:
  • ((U Integer+ IRed)) → (Array java.lang.Byte)

  • (Integer+ ⨯ Any) → (Array java.lang.Byte)

Creates an array of bytes.

byte-array?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (byte-array? x)

Type signature: Predicate

Returns true if x is a byte array, false otherwise.

See also: bytes, byte-array

bytes

Available since version 1.0 (alias of clojure.core/bytes)

not referred automatically

Usage:
  • (bytes xs)

Type signature:
  • (Any) → (Array java.lang.Byte)

Cast to byte[]

See also: byte-array, byte-array?

char-array

Available since version 1.0 (alias of clojure.core/char-array)

not referred automatically

Usage:
  • (char-array size-or-seq)

  • (char-array size init-val-or-seq)

Type signatures:
  • ((U Integer+ IRed)) → (Array java.lang.Character)

  • (Integer+ ⨯ Any) → (Array java.lang.Character)

Creates an array of chars.

char-array?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (char-array? x)

Type signature: Predicate

Returns true if x is a char array, false otherwise.

See also: chars, char-array

chars

Available since version 1.0 (alias of clojure.core/chars)

not referred automatically

Usage:
  • (chars xs)

Type signature:
  • (Any) → (Array java.lang.Character)

Cast to char[]

See also: char-array, char-array?

double-array

Available since version 1.0 (alias of clojure.core/double-array)

not referred automatically

Usage:
  • (double-array size-or-seq)

  • (double-array size init-val-or-seq)

Type signatures:
  • ((U Integer+ IRed)) → (Array java.lang.Double)

  • (Integer+ ⨯ Any) → (Array java.lang.Double)

Creates an array of doubles.

double-array?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (double-array? x)

Type signature: Predicate

Returns true if x is a double array, false otherwise.

See also: doubles, double-array

doubles

Available since version 1.0 (alias of clojure.core/doubles)

not referred automatically

Usage:
  • (doubles xs)

Type signature:
  • (Any) → (Array java.lang.Double)

Cast to double[]

float-array

Available since version 1.0 (alias of clojure.core/float-array)

not referred automatically

Usage:
  • (float-array size-or-seq)

  • (float-array size init-val-or-seq)

Type signatures:
  • ((U Integer+ IRed)) → (Array java.lang.Float)

  • (Integer+ ⨯ Any) → (Array java.lang.Float)

Creates an array of floats.

float-array?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (float-array? x)

Type signature: Predicate

Returns true if x is a float array, false otherwise.

See also: floats, float-array

floats

Available since version 1.0 (alias of clojure.core/floats)

not referred automatically

Usage:
  • (floats xs)

Type signature:
  • (Any) → (Array java.lang.Float)

Cast to float[]

int-array

Available since version 1.0 (alias of clojure.core/int-array)

not referred automatically

Usage:
  • (int-array size-or-seq)

  • (int-array size init-val-or-seq)

Type signatures:
  • ((U Integer+ IRed)) → (Array java.lang.Integer)

  • (Integer+ ⨯ Any) → (Array java.lang.Integer)

Creates an array of ints.

int-array?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (int-array? x)

Type signature: Predicate

Returns true if x is an array, false otherwise.

See also: ints, int-array

ints

Available since version 1.0 (alias of clojure.core/ints)

not referred automatically

Usage:
  • (ints xs)

Type signature:
  • (Any) → (Array java.lang.Integer)

Cast to int[]

See also: int-array, int-array?

long-array

Available since version 1.0 (alias of clojure.core/long-array)

not referred automatically

Usage:
  • (long-array size-or-seq)

  • (long-array size init-val-or-seq)

Type signatures:
  • ((U Integer+ IRed)) → (Array java.lang.Long)

  • (Integer+ ⨯ Any) → (Array java.lang.Long)

Creates an array of longs.

long-array?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (long-array? x)

Type signature: Predicate

Returns true if x is a long array, false otherwise.

See also: longs, long-array

longs

Available since version 1.0 (alias of clojure.core/longs)

not referred automatically

Usage:
  • (longs xs)

Type signature:
  • (Any) → (Array java.lang.Long)

Cast to long[]

See also: long-array, long-array?

short-array

Available since version 1.0 (alias of clojure.core/short-array)

not referred automatically

Usage:
  • (short-array size-or-seq)

  • (short-array size init-val-or-seq)

Type signatures:
  • ((U Integer+ IRed)) → (Array java.lang.Short)

  • (Integer+ ⨯ Any) → (Array java.lang.Short)

Creates an array of shorts.

short-array?

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (short-array? x)

Type signature: Predicate

Returns true if x is a short array, false otherwise.

See also: shorts, short-array

shorts

Available since version 1.0 (alias of clojure.core/shorts)

not referred automatically

Usage:
  • (shorts xs)

Type signature:
  • (Any) → (Array java.lang.Short)

Cast to short[]