A vector holding primitive values. A sequential persistent collection.

This collection type stores unboxed primitive items, while preserving all characteristics of persistent vectors.

Current implementation is based on RRB-Tree vectors.
Current API is tied to the JVM host and its primitive data types.

Primitive vectors have support for transients, folding, batched reduce, efficient reversion, sectioning and slicing. Besides primitive vector type, Dunaj offers following persistent vector types:

  • BVT vectors for efficient representation of medium to large vectors

  • tuples for efficient representation of small vectors

  • RRB-Tree vectors for efficient catenation or insertion/removal of items in the middle of a vector.

Just like all vector types, primitive vectors add/remove items to/from the rear of the collection.

Except for very special cases, it is idiomatic to use functions defined in coll.default rather than ones in this namespace.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(def v (take 1000000 (cycle (vec (range -100 100)))))
;;=> #'foo.bar/v

(def vp (vec-of :byte v))
;;=> #'foo.bar/vp

;; primitive vectors support batched reduce and they internally store data in primitive arrays. All this can speed up collection operations.

(time (with-scope (write! "out.bin" v)))
;; Elapsed time: 215.490853 msecs
;;=> 1000000

(time (with-scope (write! "out.bin" vp)))
;; Elapsed time: 70.27703 msecs
;;=> 1000000

(time (take 10 (sort v)))
;; Elapsed time: Elapsed time: 1887.72503 msecs
;;=> (-100 -100 -100 -100 -100 -100 -100 -100 -100 -100)

(time (take 10 (sort vp)))
;; Elapsed time: 261.35322 msecs
;;=> (-100 -100 -100 -100 -100 -100 -100 -100 -100 -100)

Primary

empty-byte-vec

Available since version 1.0 (view source)

not referred automatically

VAR of type PrimitiveVector

An empty primitive byte vector.

This var is specific to JVM host.

empty-char-vec

Available since version 1.0 (view source)

not referred automatically

VAR of type PrimitiveVector

An empty primitive char vector.

This var is specific to JVM host.

empty-double-vec

Available since version 1.0 (view source)

not referred automatically

VAR of type PrimitiveVector

An empty primitive double vector.

This var is specific to JVM host.

empty-float-vec

Available since version 1.0 (view source)

not referred automatically

VAR of type PrimitiveVector

An empty primitive float vector.

This var is specific to JVM host.

empty-int-vec

Available since version 1.0 (view source)

not referred automatically

VAR of type PrimitiveVector

An empty primitive int vector.

This var is specific to JVM host.

empty-long-vec

Available since version 1.0 (view source)

not referred automatically

VAR of type PrimitiveVector

An empty primitive long vector.

This var is specific to JVM host.

empty-primitive-vector-of

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (empty-primitive-vector-of t)

Type signature:
  • ((U nil Class+ Type)) → IPersistentVector

Returns an empty primitive vector of given type t, which can be a host class, a type or a keyword. See keyword→class for the list of valid keywords.

empty-short-vec

Available since version 1.0 (view source)

not referred automatically

VAR of type PrimitiveVector

An empty primitive short vector.

This var is specific to JVM host.

Factories

Note that there is no primitive vector factory for booleans, as there is no batch support for them.

byte-vec-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type ICollectionFactory

A primitive byte vector factory instance. Currently there are no options.

This factory implements ICollectionFactory factory protocol.

New instances of primitive vector can be created with collection and ->collection.

This var is specific to JVM host.

char-vec-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type ICollectionFactory

A primitive char vector factory instance. Currently there are no options.

This factory implements ICollectionFactory factory protocol.

New instances of primitive vector can be created with collection and ->collection.

This var is specific to JVM host.

double-vec-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type ICollectionFactory

A primitive double vector factory instance. Currently there are no options.

This factory implements ICollectionFactory factory protocol.

New instances of primitive vector can be created with collection and ->collection.

This var is specific to JVM host.

float-vec-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type ICollectionFactory

A primitive float vector factory instance. Currently there are no options.

This factory implements ICollectionFactory factory protocol.

New instances of primitive vector can be created with collection and ->collection.

This var is specific to JVM host.

int-vec-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type ICollectionFactory

A primitive int vector factory instance. Currently there are no options.

More Int related functions can be found in dunaj.host.int namespace.

This factory implements ICollectionFactory factory protocol.

New instances of primitive vector can be created with collection and ->collection.

This var is specific to JVM host.

long-vec-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type ICollectionFactory

A primitive long vector factory instance. Currently there are no options.

This factory implements ICollectionFactory factory protocol.

New instances of primitive vector can be created with collection and ->collection.

This var is specific to JVM host.

primitive-vector-factory-of

Available since version 1.0 (view source)

not referred automatically

Usage:
  • (primitive-vector-factory-of t)

Type signature:
  • ((U nil Class+ Type)) → ICollectionFactory

Returns a primitive vector factory for type t, which can be a host class, a type or a keyword. See keyword→class for the list of valid keywords.

New instances of primitive vector can be created with collection and ->collection.

short-vec-factory

Available since version 1.0 (view source)

not referred automatically

VAR of type ICollectionFactory

A primitive short vector factory instance. Currently there are no options.

This factory implements ICollectionFactory factory protocol.

New instances of primitive vector can be created with collection and ->collection.

This var is specific to JVM host.