Added function to get Array size.
Added new operators to Vector.
This commit is contained in:
parent
b607653e9f
commit
359c9ec343
@ -97,6 +97,8 @@ namespace PolyVox
|
||||
void resize(const uint32_t (&pDimensions)[noOfDims]);
|
||||
///Swaps the contents of this array with the one specified
|
||||
void swap(Array<noOfDims, ElementType>& rhs);
|
||||
///Get the size of the Array along the specified dimension
|
||||
uint32_t getDimension(uint32_t uDimension);
|
||||
|
||||
private:
|
||||
Array<noOfDims, ElementType>(const Array<noOfDims, ElementType>& rhs);
|
||||
|
@ -155,7 +155,7 @@ namespace PolyVox
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Because this class does not have a public assignment operator or copy constructor
|
||||
/// it cnnot be used with the STL swap() function. This function provides an efficient
|
||||
/// it cannot be used with the STL swap() function. This function provides an efficient
|
||||
/// implementation of that feature.
|
||||
/// \param rhs The array to swap this object with.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -180,6 +180,16 @@ namespace PolyVox
|
||||
rhs.m_pElements = m_pTempElements;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \param uDimension The dimension to get the size of.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <uint32_t noOfDims, typename ElementType>
|
||||
uint32_t Array<noOfDims, ElementType>::getDimension(uint32_t uDimension)
|
||||
{
|
||||
assert(uDimension < noOfDims);
|
||||
return m_pDimensions[uDimension];
|
||||
}
|
||||
|
||||
template <uint32_t noOfDims, typename ElementType>
|
||||
Array<noOfDims, ElementType>::Array(const Array<noOfDims, ElementType>& rhs)
|
||||
:m_pElements(0)
|
||||
|
@ -85,6 +85,10 @@ namespace PolyVox
|
||||
///Subtraction and Assignment Operator.
|
||||
Vector<Size,Type>& operator-=(const Vector<Size,Type> &rhs) throw();
|
||||
///Multiplication and Assignment Operator.
|
||||
Vector<Size,Type>& operator*=(const Vector<Size,Type> &rhs) throw();
|
||||
///Division and Assignment Operator.
|
||||
Vector<Size,Type>& operator/=(const Vector<Size,Type> &rhs) throw();
|
||||
///Multiplication and Assignment Operator.
|
||||
Vector<Size,Type>& operator*=(const Type& rhs) throw();
|
||||
///Division and Assignment Operator.
|
||||
Vector<Size,Type>& operator/=(const Type& rhs) throw();
|
||||
@ -143,6 +147,12 @@ namespace PolyVox
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
||||
///Multiplication operator.
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
||||
///Division operator.
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator/(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
||||
///Multiplication operator.
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw();
|
||||
///Division operator.
|
||||
|
@ -190,20 +190,6 @@ namespace PolyVox
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
Addition operator adds corresponding elements of the two Vectors.
|
||||
\param lhs Vector to add to.
|
||||
\param rhs Vector to add.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator+(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
result += rhs;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
Subtraction operator subtracts corresponding elements of one Vector from the other.
|
||||
\param rhs Vector to subtract
|
||||
@ -220,17 +206,33 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Subtraction operator subtracts corresponding elements of one Vector from the other.
|
||||
\param lhs Vector to subtract from.
|
||||
\param rhs Vector to subtract.
|
||||
Multiplication operator multiplies corresponding elements of the two Vectors.
|
||||
\param rhs Vector to multiply by
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::operator*=(const Vector<Size, Type>& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
result -= rhs;
|
||||
return result;
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
m_tElements[ct] *= rhs.m_tElements[ct];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
Division operator divides corresponding elements of one Vector by the other.
|
||||
\param rhs Vector to divide by
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::operator/=(const Vector<Size, Type>& rhs) throw()
|
||||
{
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
m_tElements[ct] /= rhs.m_tElements[ct];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,20 +250,6 @@ namespace PolyVox
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
Multiplication operator multiplies each element of the Vector by a number.
|
||||
\param lhs the Vector to multiply.
|
||||
\param rhs the number the Vector is multiplied by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
result *= rhs;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
Division operator divides each element of the Vector by a number.
|
||||
\param rhs the number the Vector is divided by.
|
||||
@ -277,6 +265,76 @@ namespace PolyVox
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
Addition operator adds corresponding elements of the two Vectors.
|
||||
\param lhs Vector to add to.
|
||||
\param rhs Vector to add.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator+(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
result += rhs;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
Subtraction operator subtracts corresponding elements of one Vector from the other.
|
||||
\param lhs Vector to subtract from.
|
||||
\param rhs Vector to subtract.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
result -= rhs;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
Multiplication operator mulitplies corresponding elements of the two Vectors.
|
||||
\param lhs Vector to multiply.
|
||||
\param rhs Vector to multiply by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
result *= rhs;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
Division operator divides corresponding elements of one Vector by the other.
|
||||
\param lhs Vector to divide.
|
||||
\param rhs Vector to divide by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator/(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
result /= rhs;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
Multiplication operator multiplies each element of the Vector by a number.
|
||||
\param lhs the Vector to multiply.
|
||||
\param rhs the number the Vector is multiplied by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
result *= rhs;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
Division operator divides each element of the Vector by a number.
|
||||
\param lhs the Vector to divide.
|
||||
|
Loading…
x
Reference in New Issue
Block a user