Create a Fixed Array#

Synopsis#

Create a FixedArray

Results#

Output::

[0, 1]

Code#

C++#

#include <iostream>
#include "itkFixedArray.h"

int
main()
{
  itk::FixedArray<double, 2> array;
  array[0] = 0;
  array[1] = 1;

  std::cout << array << std::endl;

  return EXIT_SUCCESS;
}

Python#

#!/usr/bin/env python

import itk

array = itk.FixedArray[itk.D, 2]()
array[0] = 0
array[1] = 1

print(array)

Classes demonstrated#

template<typename TValue, unsigned int VLength = 3>
class FixedArray

Simulate a standard C array with copy semantics.

Simulates a standard C array, except that copy semantics are used instead of reference semantics. Also, arrays of different sizes cannot be assigned to one another, and size information is known for function returns.

The length of the array is fixed at compile time. If you wish to specify the length of the array at run-time, use the class

itk::Array. If you wish to change to change the length of the array at run-time, you’re best off using std::vector<>.
Template Parameters
  • TValue: Element type stored at each location in the array.

  • VLength: = Length of the array.

ITK Sphinx Examples:

See itk::FixedArray for additional documentation.