More work on multidimensional Array class.

This commit is contained in:
David Williams
2010-03-28 23:18:50 +00:00
parent 834b747171
commit 3e1c07550b
3 changed files with 223 additions and 146 deletions

View File

@ -27,50 +27,50 @@ namespace PolyVox
{
template <uint32_t noOfDims, typename ElementType>
SubArray<noOfDims-1, ElementType> SubArray<noOfDims, ElementType>::operator[](uint32_t uIndex)
{
assert(uIndex<m_pDimensions[0]);
return
SubArray<noOfDims-1, ElementType>(&m_pElements[uIndex*m_pOffsets[0]],
m_pDimensions+1, m_pOffsets+1);
}
{
assert(uIndex<m_pDimensions[0]);
return
SubArray<noOfDims-1, ElementType>(&m_pElements[uIndex*m_pOffsets[0]],
m_pDimensions+1, m_pOffsets+1);
}
template <uint32_t noOfDims, typename ElementType>
const SubArray<noOfDims-1, ElementType> SubArray<noOfDims, ElementType>::operator[](uint32_t uIndex) const
{
assert(uIndex<m_pDimensions[0]);
return
SubArray<noOfDims-1, ElementType>(&m_pElements[uIndex*m_pOffsets[0]],
m_pDimensions+1, m_pOffsets+1);
}
template <uint32_t noOfDims, typename ElementType>
const SubArray<noOfDims-1, ElementType> SubArray<noOfDims, ElementType>::operator[](uint32_t uIndex) const
{
assert(uIndex<m_pDimensions[0]);
return
SubArray<noOfDims-1, ElementType>(&m_pElements[uIndex*m_pOffsets[0]],
m_pDimensions+1, m_pOffsets+1);
}
template <uint32_t noOfDims, typename ElementType>
SubArray<noOfDims, ElementType>::SubArray<noOfDims, ElementType>(ElementType * pElements, uint32_t * pDimensions, uint32_t * pOffsets)
:m_pElements(pElements)
,m_pDimensions(pDimensions)
,m_pOffsets(pOffsets)
,m_uNoOfElements(0)
{
}
template <uint32_t noOfDims, typename ElementType>
SubArray<noOfDims, ElementType>::SubArray<noOfDims, ElementType>(ElementType * pElements, uint32_t * pDimensions, uint32_t * pOffsets)
:m_pElements(pElements)
,m_pDimensions(pDimensions)
,m_pOffsets(pOffsets)
,m_uNoOfElements(0)
{
}
template <typename ElementType>
ElementType& SubArray<1, ElementType>::operator[] (uint32_t uIndex)
{
assert(uIndex<m_pDimensions[0]);
return m_pElements[uIndex];
}
template <typename ElementType>
ElementType& SubArray<1, ElementType>::operator[] (uint32_t uIndex)
{
assert(uIndex<m_pDimensions[0]);
return m_pElements[uIndex];
}
template <typename ElementType>
const ElementType& SubArray<1, ElementType>::operator[] (uint32_t uIndex) const
{
assert(uIndex<m_pDimensions[0]);
return m_pElements[uIndex];
}
template <typename ElementType>
SubArray<1, ElementType>::SubArray<1, ElementType>(ElementType * pElements, uint32_t * pDimensions, uint32_t * /*pOffsets*/)
:m_pDimensions(pDimensions)
,m_pElements(pElements)
{
}
template <typename ElementType>
const ElementType& SubArray<1, ElementType>::operator[] (uint32_t uIndex) const
{
assert(uIndex<m_pDimensions[0]);
return m_pElements[uIndex];
}
template <typename ElementType>
SubArray<1, ElementType>::SubArray<1, ElementType>(ElementType * pElements, uint32_t * pDimensions, uint32_t * /*pOffsets*/)
:m_pDimensions(pDimensions)
,m_pElements(pElements)
{
}
}//namespace PolyVox