mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-25 16:18:57 +08:00
vector cleanup
This commit is contained in:
parent
7bb52d1345
commit
ed3ffa952a
|
@ -30,7 +30,7 @@ namespace Blah
|
||||||
int size() const;
|
int size() const;
|
||||||
int capacity() const;
|
int capacity() const;
|
||||||
|
|
||||||
void reserve(size_t new_capacity);
|
void reserve(int new_capacity);
|
||||||
void resize(int new_count);
|
void resize(int new_count);
|
||||||
T* expand(int amount = 1);
|
T* expand(int amount = 1);
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ namespace Blah
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void Vector<T>::reserve(size_t cap)
|
inline void Vector<T>::reserve(int cap)
|
||||||
{
|
{
|
||||||
if (cap > m_capacity)
|
if (cap > m_capacity)
|
||||||
{
|
{
|
||||||
|
@ -213,17 +213,13 @@ namespace Blah
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void Vector<T>::push_back(const T& item)
|
inline void Vector<T>::push_back(const T& item)
|
||||||
{
|
{
|
||||||
reserve(m_count + 1);
|
emplace_back(item);
|
||||||
new (m_buffer + m_count) T(item);
|
|
||||||
m_count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void Vector<T>::push_back(T&& item)
|
inline void Vector<T>::push_back(T&& item)
|
||||||
{
|
{
|
||||||
reserve(m_count + 1);
|
emplace_back(std::move(item));
|
||||||
new (m_buffer + m_count) T(std::move(item));
|
|
||||||
m_count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user