53 lines
713 B
C++
53 lines
713 B
C++
#pragma once
|
|
#include <luna/Types.h>
|
|
|
|
template <typename T> class Slice
|
|
{
|
|
typedef T* Iterator;
|
|
typedef const T* ConstIterator;
|
|
|
|
public:
|
|
Slice(T* data, usize size) : m_data(data), m_size(size)
|
|
{
|
|
}
|
|
|
|
const T* data() const
|
|
{
|
|
return m_data;
|
|
}
|
|
|
|
T* data()
|
|
{
|
|
return m_data;
|
|
}
|
|
|
|
usize size() const
|
|
{
|
|
return m_size;
|
|
}
|
|
|
|
Iterator begin()
|
|
{
|
|
return m_data;
|
|
}
|
|
|
|
ConstIterator begin() const
|
|
{
|
|
return m_data;
|
|
}
|
|
|
|
Iterator end()
|
|
{
|
|
return m_data + m_size;
|
|
}
|
|
|
|
ConstIterator end() const
|
|
{
|
|
return m_data + m_size;
|
|
}
|
|
|
|
private:
|
|
T* const m_data;
|
|
const usize m_size;
|
|
};
|