"ListVector" (Compiled Type)

"ListVector"::[type]

represents a uniform list with the specified element type.

Details

  • "ListVector" can be used in Typed and related constructs to specify a type.
  • The elements of a "ListVector" can have any compiled type.
  • The elements of a "ListVector" all have the same type.
  • For numerical tensors with rank greater than 1, "PackedArray" or "NumericArray" can be used.

Constructors

  • "ListVector" objects can be constructed with Typed[{},"ListVector"::[type]] in compiled code. »
  • CreateTypeInstance["ListVector"::[type],carr,len] constructs a "ListVector" from a "CArray" carr with length len. carr can optionally be wrapped in "Managed".

Properties

  • Information[list,"ElementType"] for list of type "ListVector"::[type] gives type.

Conversions

    Expressions

  • List expressions can be converted to and from "ListVector"::[type] as long as every element of the list can be converted to type.
  • "PackedArray"

  • "ListVector" objects can be converted to and from "PackedArray" objects.
  • "NumericArray"

  • "ListVector" objects can be converted to and from "NumericArray" objects.

Runtime Errors

    ArrayPartError

  • Operations that require extracting elements from a "ListVector" can give a runtime error if those elements do not exist.

Examples

open allclose all

Basic Examples  (2)

"ListVector" can be used as input or output for a CompiledCodeFunction:

Create a "ListVector" in compiled code:

Scope  (3)

"ListVector" objects can contain objects with any compilable type:

Higher-rank arrays can be represented with nested "ListVector" instances:

Get the element type of a "ListVector":

Properties & Relations  (1)

The "PackedArray" can be used to represent numerical arrays:

However, it cannot be used for non-numerical data:

In contrast, the "ListVector" type can only represent rank-1 lists, but it can have elements with any compilable type:

Possible Issues  (1)

Part access can cause a runtime error: