SparsePtr: Allowed negative stride
Former-commit-id: 9ca3101347bdc071503ec9edb75b4f896a6dd2e0
This commit is contained in:
parent
15ddc29179
commit
20607238df
|
|
@ -21,34 +21,34 @@ class NzSparsePtr
|
||||||
|
|
||||||
NzSparsePtr();
|
NzSparsePtr();
|
||||||
NzSparsePtr(T* ptr);
|
NzSparsePtr(T* ptr);
|
||||||
NzSparsePtr(VoidPtr ptr, unsigned int stride);
|
NzSparsePtr(VoidPtr ptr, int stride);
|
||||||
template<typename U> NzSparsePtr(const NzSparsePtr<U>& ptr);
|
template<typename U> NzSparsePtr(const NzSparsePtr<U>& ptr);
|
||||||
NzSparsePtr(const NzSparsePtr& ptr) = default;
|
NzSparsePtr(const NzSparsePtr& ptr) = default;
|
||||||
~NzSparsePtr() = default;
|
~NzSparsePtr() = default;
|
||||||
|
|
||||||
VoidPtr GetPtr() const;
|
VoidPtr GetPtr() const;
|
||||||
unsigned int GetStride() const;
|
int GetStride() const;
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
void Reset(T* ptr);
|
void Reset(T* ptr);
|
||||||
void Reset(VoidPtr ptr, unsigned int stride);
|
void Reset(VoidPtr ptr, int stride);
|
||||||
void Reset(const NzSparsePtr& ptr);
|
void Reset(const NzSparsePtr& ptr);
|
||||||
template<typename U> void Reset(const NzSparsePtr<U>& ptr);
|
template<typename U> void Reset(const NzSparsePtr<U>& ptr);
|
||||||
|
|
||||||
void SetPtr(VoidPtr ptr);
|
void SetPtr(VoidPtr ptr);
|
||||||
void SetStride(unsigned int stride);
|
void SetStride(int stride);
|
||||||
|
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
operator T*() const;
|
operator T*() const;
|
||||||
T& operator*() const;
|
T& operator*() const;
|
||||||
T& operator->() const;
|
T& operator->() const;
|
||||||
T& operator[](unsigned int index) const;
|
T& operator[](int index) const;
|
||||||
|
|
||||||
NzSparsePtr operator+(unsigned int count) const;
|
NzSparsePtr operator+(int count) const;
|
||||||
NzSparsePtr operator-(unsigned int count) const;
|
NzSparsePtr operator-(int count) const;
|
||||||
|
|
||||||
NzSparsePtr& operator+=(unsigned int count);
|
NzSparsePtr& operator+=(int count);
|
||||||
NzSparsePtr& operator-=(unsigned int count);
|
NzSparsePtr& operator-=(int count);
|
||||||
|
|
||||||
NzSparsePtr& operator++();
|
NzSparsePtr& operator++();
|
||||||
NzSparsePtr operator++(int);
|
NzSparsePtr operator++(int);
|
||||||
|
|
@ -67,7 +67,7 @@ class NzSparsePtr
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BytePtr m_ptr;
|
BytePtr m_ptr;
|
||||||
unsigned int m_stride;
|
int m_stride;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <Nazara/Core/SparsePtr.inl>
|
#include <Nazara/Core/SparsePtr.inl>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ NzSparsePtr<T>::NzSparsePtr(T* ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzSparsePtr<T>::NzSparsePtr(VoidPtr ptr, unsigned int stride)
|
NzSparsePtr<T>::NzSparsePtr(VoidPtr ptr, int stride)
|
||||||
{
|
{
|
||||||
Reset(ptr, stride);
|
Reset(ptr, stride);
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +36,7 @@ typename NzSparsePtr<T>::VoidPtr NzSparsePtr<T>::GetPtr() const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
unsigned int NzSparsePtr<T>::GetStride() const
|
int NzSparsePtr<T>::GetStride() const
|
||||||
{
|
{
|
||||||
return m_stride;
|
return m_stride;
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ void NzSparsePtr<T>::Reset(T* ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzSparsePtr<T>::Reset(VoidPtr ptr, unsigned int stride)
|
void NzSparsePtr<T>::Reset(VoidPtr ptr, int stride)
|
||||||
{
|
{
|
||||||
SetPtr(ptr);
|
SetPtr(ptr);
|
||||||
SetStride(stride);
|
SetStride(stride);
|
||||||
|
|
@ -86,7 +86,7 @@ void NzSparsePtr<T>::SetPtr(VoidPtr ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void NzSparsePtr<T>::SetStride(unsigned int stride)
|
void NzSparsePtr<T>::SetStride(int stride)
|
||||||
{
|
{
|
||||||
m_stride = stride;
|
m_stride = stride;
|
||||||
}
|
}
|
||||||
|
|
@ -116,25 +116,25 @@ T& NzSparsePtr<T>::operator->() const
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T& NzSparsePtr<T>::operator[](unsigned int index) const
|
T& NzSparsePtr<T>::operator[](int index) const
|
||||||
{
|
{
|
||||||
return *reinterpret_cast<T*>(m_ptr + index*m_stride);
|
return *reinterpret_cast<T*>(m_ptr + index*m_stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzSparsePtr<T> NzSparsePtr<T>::operator+(unsigned int count) const
|
NzSparsePtr<T> NzSparsePtr<T>::operator+(int count) const
|
||||||
{
|
{
|
||||||
return NzSparsePtr(m_ptr + count*m_stride, m_stride);
|
return NzSparsePtr(m_ptr + count*m_stride, m_stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzSparsePtr<T> NzSparsePtr<T>::operator-(unsigned int count) const
|
NzSparsePtr<T> NzSparsePtr<T>::operator-(int count) const
|
||||||
{
|
{
|
||||||
return NzSparsePtr(m_ptr - count*m_stride, m_stride);
|
return NzSparsePtr(m_ptr - count*m_stride, m_stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzSparsePtr<T>& NzSparsePtr<T>::operator+=(unsigned int count)
|
NzSparsePtr<T>& NzSparsePtr<T>::operator+=(int count)
|
||||||
{
|
{
|
||||||
m_ptr += count*m_stride;
|
m_ptr += count*m_stride;
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ NzSparsePtr<T>& NzSparsePtr<T>::operator+=(unsigned int count)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzSparsePtr<T>& NzSparsePtr<T>::operator-=(unsigned int count)
|
NzSparsePtr<T>& NzSparsePtr<T>::operator-=(int count)
|
||||||
{
|
{
|
||||||
m_ptr -= count*m_stride;
|
m_ptr -= count*m_stride;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue