+/* Remove the element at position IX 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>::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;
+}
+
+/* Remove the element at position IX from VEC, preserving the order the
+ remaining elements. Return the removed element. */
+
+template <typename T>
+T
+ordered_remove (std::vector<T> &vec, typename std::vector<T>::size_type ix)
+{
+ gdb_assert (ix < vec.size ());
+
+ T removed = std::move (vec[ix]);
+ vec.erase (vec.begin () + ix);
+
+ return removed;
+}
+