diff options
| author | danilalexeev <[email protected]> | 2023-11-17 20:49:43 +0300 |
|---|---|---|
| committer | danilalexeev <[email protected]> | 2023-11-17 21:17:35 +0300 |
| commit | 426dffb1f0124ce8f46f3f012cb6297b88e04785 (patch) | |
| tree | c7ec55c62331954d365266a05c71e625b6624985 | |
| parent | 03f188111211d64677ea001d0f1ded8e392b9d27 (diff) | |
YT-18523: Sequoia recursive Create upgrade
| -rw-r--r-- | yt/yt/core/misc/collection_helpers-inl.h | 7 | ||||
| -rw-r--r-- | yt/yt/core/misc/collection_helpers.h | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/yt/yt/core/misc/collection_helpers-inl.h b/yt/yt/core/misc/collection_helpers-inl.h index 0b50ba117a5..fa4ccc6b73d 100644 --- a/yt/yt/core/misc/collection_helpers-inl.h +++ b/yt/yt/core/misc/collection_helpers-inl.h @@ -350,6 +350,13 @@ const T& VectorAtOr(const std::vector<T>& vector, ssize_t index, const T& defaul return index < static_cast<ssize_t>(vector.size()) ? vector[index] : defaultValue; } +template <class T> +bool CheckIfValuesUnique(std::vector<T> vector) +{ + std::sort(vector.begin(), vector.end()); + return std::unique(vector.begin(), vector.end()) == vector.end(); +} + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT diff --git a/yt/yt/core/misc/collection_helpers.h b/yt/yt/core/misc/collection_helpers.h index 9719a5da6c0..50dad94db7c 100644 --- a/yt/yt/core/misc/collection_helpers.h +++ b/yt/yt/core/misc/collection_helpers.h @@ -154,6 +154,10 @@ void AssignVectorAt(std::vector<T>& vector, ssize_t index, T&& value, const T& d template <class T> const T& VectorAtOr(const std::vector<T>& vector, ssize_t index, const T& defaultValue = T()); +//! Checks if values stored in vector are unique. +template <class T> +bool CheckIfValuesUnique(std::vector<T> vector); + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT |
