// erase the first occurrence of a value, // IF THE VALUE OCCURS template<class T, uint LEN> inline void maybe_erase(ShortVec<T,LEN> &vec, T val) { uint N = vec.size(); for(uint i=0; i<N; i++) { if(vec[i] == val) { std::swap(vec[i], vec[N-1]); vec.resize(N-1); break; } } }
// erase the first occurrence of a value from a short vector, // !!! KNOWING that it MUST BE PRESENT template<class T, uint LEN> inline void remove(ShortVec<T,LEN> &vec, T val) { uint last_i = vec.size()-1; for(uint i=0; i<last_i; i++) { if(vec[i] == val) { std::swap(vec[i], vec[last_i]); break; } } vec.resize(last_i); }