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,22 +213,18 @@ 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>
|
||||||
template<class ...Args>
|
template<class ...Args>
|
||||||
inline void Vector<T>::emplace_back(Args && ...args)
|
inline void Vector<T>::emplace_back(Args&& ...args)
|
||||||
{
|
{
|
||||||
reserve(m_count + 1);
|
reserve(m_count + 1);
|
||||||
new (m_buffer + m_count) T(std::forward<Args>(args)...);
|
new (m_buffer + m_count) T(std::forward<Args>(args)...);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user