// Copyright (c) 2008-2023 the Urho3D project // License: MIT #pragma once #include "../Container/Hash.h" namespace Urho3D { /// %Pair template class. template class Pair { public: /// Construct undefined. Pair() = default; /// Construct with values. Pair(const T& first, const U& second) : first_(first), second_(second) { } /// Test for equality with another pair. bool operator ==(const Pair& rhs) const { return first_ == rhs.first_ && second_ == rhs.second_; } /// Test for inequality with another pair. bool operator !=(const Pair& rhs) const { return first_ != rhs.first_ || second_ != rhs.second_; } /// Test for less than with another pair. bool operator <(const Pair& rhs) const { if (first_ < rhs.first_) return true; if (first_ != rhs.first_) return false; return second_ < rhs.second_; } /// Test for greater than with another pair. bool operator >(const Pair& rhs) const { if (first_ > rhs.first_) return true; if (first_ != rhs.first_) return false; return second_ > rhs.second_; } /// Return hash value for HashSet & HashMap. hash32 ToHash() const { return (MakeHash(first_) & 0xffff) | (MakeHash(second_) << 16); } /// First value. T first_; /// Second value. U second_; }; /// Construct a pair. template Pair MakePair(const T& first, const U& second) { return Pair(first, second); } template T begin(Urho3D::Pair& range) { return range.first_; } template T end(Urho3D::Pair& range) { return range.second_; } template T begin(const Urho3D::Pair& range) { return range.first_; } template T end(const Urho3D::Pair& range) { return range.second_; } }