16 #include "../base/vector.h" 29 std::map<T,size_t> id_map;
42 bool empty()
const {
return id_map.size() == 0; }
45 size_t size()
const {
return id_map.size(); }
48 const T &
operator[](
size_t pos)
const {
return vals[pos]; }
56 const size_t pos = vals.
size();
63 if (!
count(v))
return false;
66 const size_t pos = id_map[v];
70 const size_t last_pos = vals.
size() - 1;
71 if (pos != last_pos) {
72 vals[pos] = vals[last_pos];
73 id_map[vals[pos]] = pos;
80 size_t count(
const T & v)
const {
return id_map.count(v); }
ra_set()
Definition: ra_set.h:33
size_t size() const
How many elements are in this set?
Definition: ra_set.h:45
T value_type
Definition: ra_set.h:39
bool erase(const T &v)
Erase a specific value from the container.
Definition: ra_set.h:62
void push_back(PB_Ts &&...args)
Definition: vector.h:189
void insert(const T &v)
Insert a new value into container.
Definition: ra_set.h:54
size_t size() const
Definition: vector.h:151
void clear()
Remove all values from this container.
Definition: ra_set.h:51
size_t count(const T &v) const
Count the number of times a particular value in in the container (0 or 1).
Definition: ra_set.h:80
void resize(size_t new_size)
Definition: vector.h:161
If we are in emscripten, make sure to include the header.
Definition: array.h:37
bool empty() const
Are there any values in this ra_set?
Definition: ra_set.h:42
const T & operator[](size_t pos) const
Index into the ra_set, similar to a vector.
Definition: ra_set.h:48
ra_set< T > & operator=(const ra_set &)=default