23 #include <unordered_set> 33 void deleteAndShrink(std::vector<T*>& v) {
41 void clearAndShrink(std::vector<T>& v) {
46 template <
typename T,
class C>
47 void deleteAndShrink(QHash<T, C*>& h) {
53 template <
typename T,
class C>
54 void deleteAndShrink(std::map<T, C*>& m) {
63 void deleteAndShrink(std::unordered_set<C*>& s) {
76 template <
class C,
class T>
77 int indexOf(
const C& container,
const T& val) {
78 Q_ASSERT(container.size() < INT32_MAX);
79 const int s =
static_cast<int>(container.size());
80 for (
int idx = 0; idx < s; ++idx) {
81 if (container.at(idx) == val)
return idx;
92 void shuffle(std::vector<T>& vector, PRG* prg) {
93 size_t n = vector.size();
97 const size_t i = std::floor(prg->uniform() * n--);
99 const T t = vector[n];
100 vector[n] = vector[i];
Definition: abstractgraph.h:29