generalize nf7::util::Uniq
This commit is contained in:
parent
b004723464
commit
07b198f71e
@ -113,6 +113,7 @@ target_sources(nf7
|
||||
common/squashed_history.hh
|
||||
common/thread.hh
|
||||
common/timed_queue.hh
|
||||
common/util_algorithm.hh
|
||||
common/util_string.hh
|
||||
common/value.hh
|
||||
common/yas_audio.hh
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "nf7.hh"
|
||||
|
||||
#include "common/util_algorithm.hh"
|
||||
|
||||
|
||||
namespace nf7::gui {
|
||||
|
||||
|
20
common/util_algorithm.hh
Normal file
20
common/util_algorithm.hh
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace nf7::util {
|
||||
|
||||
template <typename T>
|
||||
inline void Uniq(std::vector<T>& v) noexcept {
|
||||
for (auto itr = v.begin(); itr < v.end();) {
|
||||
if (v.end() != std::find(itr+1, v.end(), *itr)) {
|
||||
itr = v.erase(itr);
|
||||
} else {
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace nf7::util
|
@ -35,15 +35,6 @@ inline void JoinAndAppend(std::string& dst, std::span<const std::string> src, ch
|
||||
dst += c;
|
||||
}
|
||||
}
|
||||
inline void Uniq(std::vector<std::string>& v) noexcept {
|
||||
for (auto itr = v.begin(); itr < v.end();) {
|
||||
if (v.end() != std::find(itr+1, v.end(), *itr)) {
|
||||
itr = v.erase(itr);
|
||||
} else {
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline std::optional<std::string_view> SplitAndValidate(
|
||||
std::string_view v,
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "common/node.hh"
|
||||
#include "common/node_root_lambda.hh"
|
||||
#include "common/ptr_selector.hh"
|
||||
#include "common/util_algorithm.hh"
|
||||
#include "common/util_string.hh"
|
||||
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "common/node_link_store.hh"
|
||||
#include "common/ptr_selector.hh"
|
||||
#include "common/squashed_history.hh"
|
||||
#include "common/util_algorithm.hh"
|
||||
#include "common/yas_imgui.hh"
|
||||
#include "common/yas_imnodes.hh"
|
||||
#include "common/yas_nf7.hh"
|
||||
|
Loading…
x
Reference in New Issue
Block a user