/* * Copyright (C) 2009 * Robert Bosch LLC * Research and Technology Center North America * Palo Alto, California * * All rights reserved. * *------------------------------------------------------------------------------ * project ....: Autonomous Technologies * file .......: rtcArray1.h * authors ....: Benjamin Pitzer * organization: Robert Bosch LLC * creation ...: 08/16/2006 * modified ...: $Date: 2009-01-21 18:19:16 -0800 (Wed, 21 Jan 2009) $ * changed by .: $Author: benjaminpitzer $ * revision ...: $Revision: 14 $ */ #ifndef RTC_ARRAY1_H #define RTC_ARRAY1_H //== INCLUDES ================================================================== #include "rtcMath.h" #include "rtcArray.h" //== NAMESPACES ================================================================ namespace rtc { // Forward declarations template class Array; // K-dimensional array template class Array1; // 1-dimensional array /** * A 1-Dimensional Array */ template class Array1: public Array { public: /// Constructors/Destructor Array1(); Array1(int len); Array1(int len, const T* d); Array1(int len, const T a); Array1(const Array& a); /// Mutators void setSize(int len); /// Accessors int size() const; /// inherit member data and functions of parent using Array::x; using Array::reset; using Array::at; protected: /// inherit member data and functions of parent using Array::dim; using Array::mul; using Array::len; }; // Declare a few common typdefs typedef Array1 Array1b; typedef Array1 Array1c; typedef Array1 Array1uc; typedef Array1 Array1i; typedef Array1 Array1f; typedef Array1 Array1d; //============================================================================== // Array1 //============================================================================== // Constructors/Destructor /** Ctor that does no initalization. */ template inline Array1::Array1() : Array() {} /** Ctor that starts with given dimensions * @param len_ size of one dimensional array */ template inline Array1::Array1(int len_) : Array() { setSize(len_); } /** Ctor that initializes elements from an array. * @param _len size of one dimensional array * @param d pointer to the initalization array */ template inline Array1::Array1(int _len, const T* d) { setSize(_len); set(d); } /** Ctor that initializes all elements from a scalar. * @param _len size of one dimensional array * @param a the value to assign to all elements */ template inline Array1::Array1(int _len, const T a) { setSize(_len); set(a); } /** Ctor that initializes an Array1 with a Array. * @param a is the array to duplicate */ template inline Array1::Array1(const Array& a) : Array(a) {} /** Set the size of the array * @param len_ size of one dimensional array */ template inline void Array1::setSize(int len_) { Array::setSize(Vec(len_)); } // Accessors /** Set the size of the array * @return size of one dimensional array */ template inline int Array1::size() const { return len; } //============================================================================== } // namespace rtc //============================================================================== #endif // RTC_ARRAY1_H defined //==============================================================================