Browse Source

Added function append_array to vector

AndreaCatania 8 years ago
parent
commit
b204389762
1 changed files with 13 additions and 0 deletions
  1. 13 0
      core/vector.h

+ 13 - 0
core/vector.h

@@ -152,6 +152,8 @@ public:
 
 
 	Error insert(int p_pos, const T &p_val);
 	Error insert(int p_pos, const T &p_val);
 
 
+	void append_array(const Vector<T> &p_other);
+
 	template <class C>
 	template <class C>
 	void sort_custom() {
 	void sort_custom() {
 
 
@@ -407,6 +409,17 @@ Error Vector<T>::insert(int p_pos, const T &p_val) {
 	return OK;
 	return OK;
 }
 }
 
 
+template <class T>
+void Vector<T>::append_array(const Vector<T> &p_other) {
+	const int ds = p_other.size();
+	if (ds == 0)
+		return;
+	const int bs = size();
+	resize(bs + ds);
+	for (int i = 0; i < ds; ++i)
+		operator[](bs + i) = p_other[i];
+}
+
 template <class T>
 template <class T>
 Vector<T>::Vector(const Vector &p_from) {
 Vector<T>::Vector(const Vector &p_from) {