maxon.BaseArray

Description

A generic array class template used to stored any kind of data. It is based on maxon.BaseCollection and maxon.Collection.

Inheritance diagram

Inheritance

Parent Class:

Methods Signature

Append(value)

Not Implemented yet, use Resize and [].

CopyFrom(other)

Flush()

Deletes all elements, but doesn’t free memory (calls destructors though).

GetCount()

Gets the number of array elements.

Insert(index, value)

Inserts a new element at index position.

Reset()

Deletes all elements (calls destructors and frees memory).

Resize(newCnt[, resizeFlags])

Resizes the array to contain newCnt elements.

ToBlock()

Returns a maxon.Block which represents the elements of the array.

__getitem__(index)

Gets the item at the given index in the array.

__init__([ob, input, count])

Initialize the BaseContainer in order to store a given type. At the moment only maxon Data Type are supported.

__iter__()

Iterates over the values in the array.

__len__()

Returns the number of elements in array.

__maxon_init__(capsule)

__repr__()

Returns the string representation of a data.

__setitem__(index, item)

Sets the item for the given index in the array.

__str__()

Returns the string representation of a data.

Methods Definition

BaseArray.Append(value)

Not Implemented yet, use Resize and [].

BaseArray.CopyFrom(other)
BaseArray.Flush()

Deletes all elements, but doesn’t free memory (calls destructors though).

BaseArray.GetCount()

Gets the number of array elements.

Returns

Number of array elements.

Return type

int

BaseArray.Insert(index, value)

Inserts a new element at index position.

Parameters
  • index (int) – position

  • value (maxon.Data) – The value to be copied.

BaseArray.Reset()

Deletes all elements (calls destructors and frees memory).

BaseArray.Resize(newCnt, resizeFlags=enums.COLLECTION_RESIZE_FLAGS.DEFAULT)
Resizes the array to contain newCnt elements.
If newCnt is smaller than BaseArray.GetCount() all extra elements are being deleted.
If it is greater the array is expanded and the default constructor is called for new elements.
Parameters
BaseArray.ToBlock()

Returns a maxon.Block which represents the elements of the array.

Returns

The content of this array as a block.

Returns

maxon.Block

BaseArray.__getitem__(index)

Gets the item at the given index in the array.

Parameters

index (int) – The index to retrieve the value for.

Raises

IndexError – When index is out of bounds.

Returns

The retrieved item.

Return type

maxon.Data

BaseArray.__init__(ob=None, input=None, count=None)
Initialize the BaseContainer in order to store a given type. At the moment only maxon Data Type are supported.

If it is an iterable the items are copied over
Parameters
  • ob (Union[str, datatype capsule, WrapperClass] (e.g. maxon.Int32 or maxon.BaseTime)) –

    If it’s a string:

    1. Example 1: “net.maxon.interface.string-C” creates an array of string objects

    2. Example 2: “net.maxon.interface.string-C[A]” creates an array of string arrays

    If it’s a datatype capsule e.g maxon.Int32 it will only accept this kind of datatype later.

  • input (Optional(Union[int, collections.Iterable])) – If it’s an integer, resize the array with this number, if it’s an iterable the data are copied.

  • count (Optional(int)) – Number of elements to fill/copy in case if input is passed.

BaseArray.__iter__()

Iterates over the values in the array.

BaseArray.__len__()

Returns the number of elements in array.

Returns

Number of elements in the array.

Return type

int

BaseArray.__maxon_init__(capsule)
BaseArray.__repr__()

Returns the string representation of a data.

Return type

str

BaseArray.__setitem__(index, item)
Sets the item for the given index in the array.

It is only possible to modify existing items with this function, to add new values, use
Parameters
  • index (int) – The index of the value to set.

  • value (Optional[maxon.Data]) – The value to set for index.

Raises

IndexError – When index is out of bounds.

BaseArray.__str__()

Returns the string representation of a data.

Return type

str