Browse Source

Add a few helper functions for std::vector.

wip/core-clipp
Sam Hocevar 4 years ago
parent
commit
c1d74196da
2 changed files with 14 additions and 2 deletions
  1. +13
    -1
      include/lol/base/private/containers.h
  2. +1
    -1
      include/lol/base/utils.h

include/lol/base/private/map.h → include/lol/base/private/containers.h View File

@@ -16,7 +16,7 @@
// //
// The map utilities // The map utilities
// ————————————————— // —————————————————
// Contains some utilities to work with std::map objects.
// Contains some utilities to work with std::map and std::vector objects.
// //


#include <vector> #include <vector>
@@ -51,5 +51,17 @@ static inline std::vector<typename T::key_type> keys(T const &m)
return ret; return ret;
} }


template <typename T>
static inline auto remove_at(std::vector<T> &v, size_t i)
{
return v.erase(v.begin() + i);
}

template <typename T>
static inline auto remove_item(std::vector<T> &v, T const &x)
{
return v.erase(std::remove(v.begin(), v.end(), x), v.end());
}

} /* namespace lol */ } /* namespace lol */



+ 1
- 1
include/lol/base/utils.h View File

@@ -13,5 +13,5 @@
#pragma once #pragma once


#include "private/string.h" #include "private/string.h"
#include "private/map.h"
#include "private/containers.h"



Loading…
Cancel
Save