vtkSparseArray< T > Class Template Reference

#include <vtkSparseArray.h>

Inheritance diagram for vtkSparseArray< T >:

Inheritance graph
[legend]
Collaboration diagram for vtkSparseArray< T >:

Collaboration graph
[legend]

List of all members.


Detailed Description

template<typename T>
class vtkSparseArray< T >

Sparse storage for N-way arrays.

vtkSparseArray is a concrete vtkArray implementation that stores values using sparse coordinate storage. This means that the array stores the complete set of coordinates and the value for each non-null value in the array, an approach that generalizes well for arbitrary numbers of dimensions.

In addition to the value retrieval and update methods provided by vtkTypedArray, vtkSparseArray provides methods to:

Get and set a special 'null' value that will be returned when retrieving values for undefined coordinates.

Clear the contents of the array so that every set of coordinates is undefined.

Add values to the array in amortized-constant time.

Resize the array extents so that they bound the largest set of non-NULL values along each dimension.

Retrieve pointers to the value- and coordinate-storage memory blocks.

See also:
vtkArray, vtkTypedArray, vtkDenseArray
Thanks:
Developed by Timothy M. Shead (tshead@sandia.gov) at Sandia National Laboratories.
Tests:
vtkSparseArray (Tests)

Definition at line 65 of file vtkSparseArray.h.


Public Member Functions

void PrintSelf (ostream &os, vtkIndent indent)
vtkArrayExtents GetExtents ()
vtkIdType GetNonNullSize ()
void GetCoordinatesN (const vtkIdType n, vtkArrayCoordinates &coordinates)
vtkArrayDeepCopy ()
const T & GetValue (const vtkArrayCoordinates &coordinates)
const T & GetValueN (const vtkIdType n)
void SetValue (const vtkArrayCoordinates &coordinates, const T &value)
void SetValueN (const vtkIdType n, const T &value)
void SetNullValue (const T &value)
const T & GetNullValue ()
void Clear ()
const vtkIdTypeGetCoordinateStorage () const
vtkIdTypeGetCoordinateStorage ()
const T * GetValueStorage () const
T * GetValueStorage ()
void ReserveStorage (const vtkIdType value_count)
void ResizeToContents ()
void AddValue (vtkIdType i, const T &value)
void AddValue (vtkIdType i, vtkIdType j, const T &value)
void AddValue (vtkIdType i, vtkIdType j, vtkIdType k, const T &value)
void AddValue (const vtkArrayCoordinates &coordinates, const T &value)

Static Public Member Functions

static vtkSparseArray< T > * New ()

Protected Member Functions

 vtkSparseArray ()
 ~vtkSparseArray ()

Constructor & Destructor Documentation

template<typename T>
vtkSparseArray< T >::vtkSparseArray (  )  [protected]

template<typename T>
vtkSparseArray< T >::~vtkSparseArray (  )  [protected]


Member Function Documentation

template<typename T>
static vtkSparseArray<T>* vtkSparseArray< T >::New (  )  [static]

Create an object with Debug turned off, modified time initialized to zero, and reference counting on.

Reimplemented from vtkObject.

template<typename T>
void vtkSparseArray< T >::PrintSelf ( ostream &  os,
vtkIndent  indent 
) [virtual]

Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkTypedArray< T >.

template<typename T>
vtkArrayExtents vtkSparseArray< T >::GetExtents (  )  [virtual]

Returns the extents (the number of dimensions and size along each dimension) of the array.

Implements vtkArray.

template<typename T>
vtkIdType vtkSparseArray< T >::GetNonNullSize (  )  [virtual]

Returns the number of non-null values stored in the array. Note that this value will equal GetSize() for dense arrays, and will be less-than-or-equal to GetSize() for sparse arrays.

Implements vtkArray.

template<typename T>
void vtkSparseArray< T >::GetCoordinatesN ( const vtkIdType  n,
vtkArrayCoordinates coordinates 
) [virtual]

Returns the coordinates of the n-th value in the array, where n is in the range [0, GetNonNullSize()). Note that the order in which coordinates are visited is undefined, but is guaranteed to match the order in which values are visited using vtkTypedArray::GetValueN() and vtkTypedArray::SetValueN().

Implements vtkArray.

template<typename T>
vtkArray* vtkSparseArray< T >::DeepCopy (  )  [virtual]

Returns a new array that is a deep copy of this array.

Implements vtkArray.

template<typename T>
const T& vtkSparseArray< T >::GetValue ( const vtkArrayCoordinates coordinates  )  [virtual]

Returns the value stored in the array at the given coordinates. Note that the number of dimensions in the supplied coordinates must match the number of dimensions in the array.

Implements vtkTypedArray< T >.

template<typename T>
const T& vtkSparseArray< T >::GetValueN ( const vtkIdType  n  )  [virtual]

Returns the n-th value stored in the array, where n is in the range [0, GetNonNullSize()). This is useful for efficiently visiting every value in the array. Note that the order in which values are visited is undefined, but is guaranteed to match the order used by vtkArray::GetCoordinatesN().

Implements vtkTypedArray< T >.

template<typename T>
void vtkSparseArray< T >::SetValue ( const vtkArrayCoordinates coordinates,
const T &  value 
) [virtual]

Overwrites the value stored in the array at the given coordinates. Note that the number of dimensions in the supplied coordinates must match the number of dimensions in the array.

Implements vtkTypedArray< T >.

template<typename T>
void vtkSparseArray< T >::SetValueN ( const vtkIdType  n,
const T &  value 
) [virtual]

Overwrites the n-th value stored in the array, where n is in the range [0, GetNonNullSize()). This is useful for efficiently visiting every value in the array. Note that the order in which values are visited is undefined, but is guaranteed to match the order used by vtkArray::GetCoordinatesN().

Implements vtkTypedArray< T >.

template<typename T>
void vtkSparseArray< T >::SetNullValue ( const T &  value  ) 

Set the value that will be returned by GetValue() for NULL areas of the array.

template<typename T>
const T& vtkSparseArray< T >::GetNullValue (  ) 

Returns the value that will be returned by GetValue() for NULL areas of the array.

template<typename T>
void vtkSparseArray< T >::Clear (  ) 

Remove all non-null elements from the array, leaving the number of dimensions, the extent of each dimension, and the label for each dimension unchanged.

template<typename T>
const vtkIdType* vtkSparseArray< T >::GetCoordinateStorage (  )  const

Return a read-only reference to the underlying coordinate storage. Coordinates are stored contiguously as a one-dimensional array with the coordinates for each value stored adjacent to one-another. The ordering of coordinates is arbitrary.

template<typename T>
vtkIdType* vtkSparseArray< T >::GetCoordinateStorage (  ) 

Return a mutable reference to the underlying coordinate storage. Coordinates are stored contiguously as a one-dimensional array with the coordinates for each value stored adjacent to one-another. The ordering of coordinates is arbitrary. Use at your own risk!

template<typename T>
const T* vtkSparseArray< T >::GetValueStorage (  )  const

Return a read-only reference to the underlying value storage. Values are stored contiguously, but in arbitrary order. Use GetCoordinateStorage() if you need to get the corresponding coordinates for a value.

template<typename T>
T* vtkSparseArray< T >::GetValueStorage (  ) 

Return a mutable reference to the underlying value storage. Values are stored contiguously, but in arbitrary order. Use GetCoordinateStorage() if you need to get the corresponding coordinates for a value. Use at your own risk!

template<typename T>
void vtkSparseArray< T >::ReserveStorage ( const vtkIdType  value_count  ) 

Reserve storage for a specific number of values. This is useful for reading external data using GetCoordinateStorage() and GetValueStorage(), when the total number of non-NULL values in the array can be determined in advance. Note that after calling ReserveStorage(), all coordinates and values will be undefined, so you must ensure that every set of coordinates and values is overwritten. It is the caller's responsibility to ensure that duplicate coordinates are not inserted into the array.

template<typename T>
void vtkSparseArray< T >::ResizeToContents (  ) 

Update the array extents to match its contents, so that the extent along each dimension matches the maximum index value along that dimension.

template<typename T>
void vtkSparseArray< T >::AddValue ( vtkIdType  i,
const T &  value 
) [inline]

Adds a new non-null element to the array. Does not test to see if an element with matching coordinates already exists. Useful for providing fast initialization of the array as long as the caller is prepared to guarantee that no duplicate coordinates are ever used.

template<typename T>
void vtkSparseArray< T >::AddValue ( vtkIdType  i,
vtkIdType  j,
const T &  value 
) [inline]

Adds a new non-null element to the array. Does not test to see if an element with matching coordinates already exists. Useful for providing fast initialization of the array as long as the caller is prepared to guarantee that no duplicate coordinates are ever used.

template<typename T>
void vtkSparseArray< T >::AddValue ( vtkIdType  i,
vtkIdType  j,
vtkIdType  k,
const T &  value 
) [inline]

Adds a new non-null element to the array. Does not test to see if an element with matching coordinates already exists. Useful for providing fast initialization of the array as long as the caller is prepared to guarantee that no duplicate coordinates are ever used.

template<typename T>
void vtkSparseArray< T >::AddValue ( const vtkArrayCoordinates coordinates,
const T &  value 
)

Adds a new non-null element to the array. Does not test to see if an element with matching coordinates already exists. Useful for providing fast initialization of the array as long as the caller is prepared to guarantee that no duplicate coordinates are ever used.


The documentation for this class was generated from the following file:

Generated on Wed Jun 3 19:35:09 2009 for VTK by  doxygen 1.5.6