aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Containers.h
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2014-06-23 16:35:54 -0500
committerSubv <subv2112@gmail.com>2014-06-23 16:35:54 -0500
commit0db743c4ff2885ae51319c897158cc8774b41a88 (patch)
tree06b1e7950dac31b879ae7802d40b7493b0c61ec4 /src/server/shared/Containers.h
parent28b61812cf0d87b84aefaa0889844b6288f93b93 (diff)
parentaa93a975469cca56e35adc1b5b501f4536be61f1 (diff)
Merge branch 'master' of github.com:TrinityCore/TrinityCore into boost
Conflicts: src/server/authserver/Server/AuthSession.cpp src/server/game/Server/WorldSession.h src/server/shared/Packets/ByteBuffer.cpp src/server/shared/Utilities/Util.h
Diffstat (limited to 'src/server/shared/Containers.h')
-rw-r--r--src/server/shared/Containers.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/server/shared/Containers.h b/src/server/shared/Containers.h
index d6ba98e4ed4..9121fbe2a97 100644
--- a/src/server/shared/Containers.h
+++ b/src/server/shared/Containers.h
@@ -64,6 +64,34 @@ namespace Trinity
std::advance(it, urand(0, container.size() - 1));
return *it;
}
+
+ /**
+ * @fn bool Trinity::Containers::Intersects(Iterator first1, Iterator last1, Iterator first2, Iterator last2)
+ *
+ * @brief Checks if two SORTED containers have a common element
+ *
+ * @param first1 Iterator pointing to start of the first container
+ * @param last1 Iterator pointing to end of the first container
+ * @param first2 Iterator pointing to start of the second container
+ * @param last2 Iterator pointing to end of the second container
+ *
+ * @return true if containers have a common element, false otherwise.
+ */
+ template<class Iterator1, class Iterator2>
+ bool Intersects(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
+ {
+ while (first1 != last1 && first2 != last2)
+ {
+ if (*first1 < *first2)
+ ++first1;
+ else if (*first2 < *first1)
+ ++first2;
+ else
+ return true;
+ }
+
+ return false;
+ }
}
//! namespace Containers
}