The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
ShortArray Class Reference

#include <ShortArray.hpp>

Public Member Functions

 ShortArray ()
 
 ShortArray (const ShortArray &)=delete
 
 ShortArray (size_t n)
 
 ~ShortArray ()
 
void clear ()
 
ShortArrayoperator= (const ShortArray &)=delete
 
double & operator[] (size_t i)
 
double operator[] (size_t i) const
 
void resize (size_t n)
 
size_t size () const
 

Static Public Attributes

static const int N
 

Private Attributes

double _a [N]
 
size_t _c
 
size_t _n
 
double * _p
 

Detailed Description

A ShortArray instance holds a an array of double values that is usually shorter than the compile-time constant ShortArray::N but can be larger if needed. As long as the array is not longer than N, no heap allocations occur. If the array does become longer than N, the appropriate space is allocated on the heap. The number of items held by the array can be adjusted, but only at the cost of erasing all previously stored values: the resize operation sets all values to zero, just as if the array was freshly constructed. ShortArray instances cannot be copied or moved.

In the current implementation, the value of N is 8.

Constructor & Destructor Documentation

◆ ShortArray() [1/3]

ShortArray::ShortArray ( )
inline

The default constructor creates an empty array.

◆ ShortArray() [2/3]

ShortArray::ShortArray ( size_t  n)
inlineexplicit

This constructor creates an empty array with the specified number of values, all initialized to zero.

◆ ShortArray() [3/3]

ShortArray::ShortArray ( const ShortArray )
delete

The copy constructor is deleted.

◆ ~ShortArray()

ShortArray::~ShortArray ( )
inline

The destructor releases the memory buffer if it was allocated on the heap.

Member Function Documentation

◆ clear()

void ShortArray::clear ( )
inline

This function clears all values held by the array to zero.

◆ operator=()

ShortArray & ShortArray::operator= ( const ShortArray )
delete

The assignment operator is deleted.

◆ operator[]() [1/2]

double & ShortArray::operator[] ( size_t  i)
inline

This function returns a writable reference to the specified array element.

◆ operator[]() [2/2]

double ShortArray::operator[] ( size_t  i) const
inline

This function returns a read-only reference to the specified array element.

◆ resize()

void ShortArray::resize ( size_t  n)
inline

This function resizes the array so that it holds the specified number of values. The values are initialized to zero; the previous contents is lost. All iterators are invalidated.

◆ size()

size_t ShortArray::size ( ) const
inline

This function returns the number of values held by the array.


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