ClojureDocs

Nav

Namespaces

vector-of

clojure.core

Available since 1.2 (source)
  • (vector-of t)
  • (vector-of t & elements)
Creates a new vector of a single primitive type t, where t is one
of :int :long :float :double :byte :short :char or :boolean. The
resulting vector complies with the interface of vectors in general,
but stores the values unboxed internally.
 Optionally takes one or more elements to populate the vector.
1 Example
user=> (conj (vector-of :int) 1 2 3)
[1 2 3]  ; <-- note, these are unboxed internally

user=> (vector-of :int 1 2 3)
[1 2 3]  ; same here

user=> (type (conj (vector-of :int) 1 2 3))
clojure.core.Vec
See Also

Creates a new vector containing the contents of coll. Java arrays will be aliased and should not b...

Added by alimoeeny

Creates a new vector containing the args.

Added by alimoeeny

Return true if x implements IPersistentVector

Added by alimoeeny
1 Note
    By , created 5.2 years ago

    The primary use of vector-of is to be space efficient. As most of Clojure deals with boxed types, boxing/unboxing will happen everytime an element is taken out/inserted.