|
@@ -1,5 +1,5 @@
|
|
|
/*-
|
|
/*-
|
|
|
- * Copyright 2012 Matthew Endsley
|
|
|
|
|
|
|
+ * Copyright 2012-1015 Matthew Endsley
|
|
|
* All rights reserved
|
|
* All rights reserved
|
|
|
*
|
|
*
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -56,6 +56,8 @@ namespace tinystl {
|
|
|
T& operator[](size_t idx);
|
|
T& operator[](size_t idx);
|
|
|
const T& operator[](size_t idx) const;
|
|
const T& operator[](size_t idx) const;
|
|
|
|
|
|
|
|
|
|
+ const T& front() const;
|
|
|
|
|
+ T& front();
|
|
|
const T& back() const;
|
|
const T& back() const;
|
|
|
T& back();
|
|
T& back();
|
|
|
|
|
|
|
@@ -67,6 +69,10 @@ namespace tinystl {
|
|
|
void push_back(const T& t);
|
|
void push_back(const T& t);
|
|
|
void pop_back();
|
|
void pop_back();
|
|
|
|
|
|
|
|
|
|
+ void emplace_back();
|
|
|
|
|
+ template<typename Param>
|
|
|
|
|
+ void emplace_back(const Param& param);
|
|
|
|
|
+
|
|
|
void shrink_to_fit();
|
|
void shrink_to_fit();
|
|
|
|
|
|
|
|
void swap(vector& other);
|
|
void swap(vector& other);
|
|
@@ -81,9 +87,13 @@ namespace tinystl {
|
|
|
const_iterator begin() const;
|
|
const_iterator begin() const;
|
|
|
const_iterator end() const;
|
|
const_iterator end() const;
|
|
|
|
|
|
|
|
|
|
+ void insert(iterator where);
|
|
|
void insert(iterator where, const T& value);
|
|
void insert(iterator where, const T& value);
|
|
|
void insert(iterator where, const T* first, const T* last);
|
|
void insert(iterator where, const T* first, const T* last);
|
|
|
|
|
|
|
|
|
|
+ template<typename Param>
|
|
|
|
|
+ void emplace(iterator where, const Param& param);
|
|
|
|
|
+
|
|
|
iterator erase(iterator where);
|
|
iterator erase(iterator where);
|
|
|
iterator erase(iterator first, iterator last);
|
|
iterator erase(iterator first, iterator last);
|
|
|
|
|
|
|
@@ -109,7 +119,7 @@ namespace tinystl {
|
|
|
template<typename T, typename Alloc>
|
|
template<typename T, typename Alloc>
|
|
|
inline vector<T, Alloc>::vector(size_t _size) {
|
|
inline vector<T, Alloc>::vector(size_t _size) {
|
|
|
buffer_init(&m_buffer);
|
|
buffer_init(&m_buffer);
|
|
|
- buffer_resize(&m_buffer, _size, T());
|
|
|
|
|
|
|
+ buffer_resize(&m_buffer, _size);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template<typename T, typename Alloc>
|
|
template<typename T, typename Alloc>
|
|
@@ -176,6 +186,16 @@ namespace tinystl {
|
|
|
return m_buffer.first[idx];
|
|
return m_buffer.first[idx];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ template<typename T, typename Alloc>
|
|
|
|
|
+ inline const T& vector<T, Alloc>::front() const {
|
|
|
|
|
+ return m_buffer.first[0];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ template<typename T, typename Alloc>
|
|
|
|
|
+ inline T& vector<T, Alloc>::front() {
|
|
|
|
|
+ return m_buffer.first[0];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
template<typename T, typename Alloc>
|
|
template<typename T, typename Alloc>
|
|
|
inline const T& vector<T, Alloc>::back() const {
|
|
inline const T& vector<T, Alloc>::back() const {
|
|
|
return m_buffer.last[-1];
|
|
return m_buffer.last[-1];
|
|
@@ -188,7 +208,7 @@ namespace tinystl {
|
|
|
|
|
|
|
|
template<typename T, typename Alloc>
|
|
template<typename T, typename Alloc>
|
|
|
inline void vector<T, Alloc>::resize(size_t _size) {
|
|
inline void vector<T, Alloc>::resize(size_t _size) {
|
|
|
- buffer_resize(&m_buffer, _size, T());
|
|
|
|
|
|
|
+ buffer_resize(&m_buffer, _size);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template<typename T, typename Alloc>
|
|
template<typename T, typename Alloc>
|
|
@@ -211,6 +231,19 @@ namespace tinystl {
|
|
|
buffer_insert(&m_buffer, m_buffer.last, &t, &t + 1);
|
|
buffer_insert(&m_buffer, m_buffer.last, &t, &t + 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ template<typename T, typename Alloc>
|
|
|
|
|
+ inline void vector<T, Alloc>::emplace_back()
|
|
|
|
|
+ {
|
|
|
|
|
+ buffer_insert(&m_buffer, m_buffer.last, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ template<typename T, typename Alloc>
|
|
|
|
|
+ template<typename Param>
|
|
|
|
|
+ inline void vector<T, Alloc>::emplace_back(const Param& param)
|
|
|
|
|
+ {
|
|
|
|
|
+ buffer_insert(&m_buffer, m_buffer.last, ¶m, ¶m + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
template<typename T, typename Alloc>
|
|
template<typename T, typename Alloc>
|
|
|
inline void vector<T, Alloc>::pop_back() {
|
|
inline void vector<T, Alloc>::pop_back() {
|
|
|
buffer_erase(&m_buffer, m_buffer.last - 1, m_buffer.last);
|
|
buffer_erase(&m_buffer, m_buffer.last - 1, m_buffer.last);
|
|
@@ -246,6 +279,11 @@ namespace tinystl {
|
|
|
return m_buffer.last;
|
|
return m_buffer.last;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ template<typename T, typename Alloc>
|
|
|
|
|
+ inline void vector<T, Alloc>::insert(vector::iterator where) {
|
|
|
|
|
+ buffer_insert(&m_buffer, where, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
template<typename T, typename Alloc>
|
|
template<typename T, typename Alloc>
|
|
|
inline void vector<T, Alloc>::insert(iterator where, const T& value) {
|
|
inline void vector<T, Alloc>::insert(iterator where, const T& value) {
|
|
|
buffer_insert(&m_buffer, where, &value, &value + 1);
|
|
buffer_insert(&m_buffer, where, &value, &value + 1);
|
|
@@ -275,6 +313,12 @@ namespace tinystl {
|
|
|
inline typename vector<T, Alloc>::iterator vector<T, Alloc>::erase_unordered(iterator first, iterator last) {
|
|
inline typename vector<T, Alloc>::iterator vector<T, Alloc>::erase_unordered(iterator first, iterator last) {
|
|
|
return buffer_erase_unordered(&m_buffer, first, last);
|
|
return buffer_erase_unordered(&m_buffer, first, last);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ template<typename T, typename Alloc>
|
|
|
|
|
+ template<typename Param>
|
|
|
|
|
+ void vector<T, Alloc>::emplace(vector::iterator where, const Param& param) {
|
|
|
|
|
+ buffer_insert(&m_buffer, where, ¶m, ¶m + 1);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
#endif
|