Cleanup ox::Vector organization
This commit is contained in:
parent
7e1866ade9
commit
e45db79a77
32
deps/ox/src/ox/std/vector.hpp
vendored
32
deps/ox/src/ox/std/vector.hpp
vendored
@ -30,10 +30,6 @@ class Vector {
|
||||
|
||||
~Vector();
|
||||
|
||||
size_t size() const;
|
||||
|
||||
void resize(size_t size);
|
||||
|
||||
Vector &operator=(Vector &other);
|
||||
|
||||
Vector &operator=(Vector &&other);
|
||||
@ -42,6 +38,10 @@ class Vector {
|
||||
|
||||
const T &operator[](size_t i) const;
|
||||
|
||||
size_t size() const;
|
||||
|
||||
void resize(size_t size);
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -52,7 +52,7 @@ Vector<T>::Vector(size_t size) {
|
||||
|
||||
template<typename T>
|
||||
Vector<T>::Vector(Vector<T> &other) {
|
||||
m_size = size;
|
||||
m_size = other.m_size;
|
||||
m_items = new T[m_size];
|
||||
for (size_t i = 0; i < m_size; i++) {
|
||||
m_items[i] = other.m_items[i];
|
||||
@ -78,7 +78,7 @@ Vector<T>::~Vector() {
|
||||
template<typename T>
|
||||
Vector<T> &Vector<T>::operator=(Vector<T> &other) {
|
||||
~Vector<T>();
|
||||
m_size = size;
|
||||
m_size = other.m_size;
|
||||
m_items = new T[m_size];
|
||||
for (size_t i = 0; i < m_size; i++) {
|
||||
m_items[i] = other.m_items[i];
|
||||
@ -96,6 +96,16 @@ Vector<T> &Vector<T>::operator=(Vector<T> &&other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T &Vector<T>::operator[](size_t i) {
|
||||
return *(m_items[i]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const T &Vector<T>::operator[](size_t i) const {
|
||||
return *(m_items[i]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
size_t Vector<T>::size() const {
|
||||
return m_size;
|
||||
@ -113,14 +123,4 @@ void Vector<T>::resize(size_t size) {
|
||||
delete[] oldItems;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T &Vector<T>::operator[](size_t i) {
|
||||
return *(m_items[i]);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const T &Vector<T>::operator[](size_t i) const {
|
||||
return *(m_items[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user