blob: ea23ebdef542b4c934ca543c8a078a4c04974c6d [file] [log] [blame]
#ifndef THIRD_PARTY_GBMCWEB_REDFISH_CORE_INCLUDE_UTILS_STL_UTILS_H_
#define THIRD_PARTY_GBMCWEB_REDFISH_CORE_INCLUDE_UTILS_STL_UTILS_H_
#include <algorithm>
namespace redfish {
namespace stl_utils {
template <typename ForwardIterator>
ForwardIterator firstDuplicate(ForwardIterator first, ForwardIterator last) {
auto newLast = first;
for (auto current = first; current != last; ++current) {
if (std::find(first, newLast, *current) == newLast) {
if (newLast != current) {
*newLast = *current;
}
++newLast;
}
}
return newLast;
}
template <typename T>
void removeDuplicate(T& t) {
t.erase(firstDuplicate(t.begin(), t.end()), t.end());
}
} // namespace stl_utils
} // namespace redfish
#endif // THIRD_PARTY_GBMCWEB_REDFISH_CORE_INCLUDE_UTILS_STL_UTILS_H_