Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / common / gdb_vecs.h
index 141d05e0189a5eb664736461ce89daa45521efe2..86803d4cb385e7e40b870709a50f9f0c2d35f0ce 100644 (file)
@@ -1,6 +1,6 @@
 /* Some commonly-used VEC types.
 
-   Copyright (C) 2012-2018 Free Software Foundation, Inc.
+   Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 
 #include "vec.h"
 
-typedef const char *const_char_ptr;
-
-DEF_VEC_P (const_char_ptr);
-
 /* Split STR, a list of DELIMITER-separated fields, into a char pointer vector.
 
    You may modify the returned strings.  */
@@ -47,6 +43,22 @@ extern void dirnames_to_char_ptr_vec_append
 extern std::vector<gdb::unique_xmalloc_ptr<char>>
   dirnames_to_char_ptr_vec (const char *dirnames);
 
+/* Remove the element pointed by iterator IT from VEC, not preserving the order
+   of the remaining elements.  Return the removed element.  */
+
+template <typename T>
+T
+unordered_remove (std::vector<T> &vec, typename std::vector<T>::iterator it)
+{
+  gdb_assert (it >= vec.begin () && it < vec.end ());
+
+  T removed = std::move (*it);
+  *it = std::move (vec.back ());
+  vec.pop_back ();
+
+  return removed;
+}
+
 /* Remove the element at position IX from VEC, not preserving the order of the
    remaining elements.  Return the removed element.  */
 
@@ -56,11 +68,7 @@ unordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
 {
   gdb_assert (ix < vec.size ());
 
-  T removed = std::move (vec[ix]);
-  vec[ix] = std::move (vec.back ());
-  vec.pop_back ();
-
-  return removed;
+  return unordered_remove (vec, vec.begin () + ix);
 }
 
 /* Remove the element at position IX from VEC, preserving the order the
This page took 0.030522 seconds and 4 git commands to generate.