diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-12-19 16:31:42 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-01-12 22:47:45 +0100 |
| commit | d9b0b7a6319b9faecfb58df7c3c772f440f09db0 (patch) | |
| tree | 58097575a0773b2cdf4feac0ccec6c50a2b8e795 /src/lib/util.h | |
| parent | 83f28a7c67794c0a9e48c8016db11585939e4d5d (diff) | |
Make PlayerText comparable.
Diffstat (limited to 'src/lib/util.h')
| -rw-r--r-- | src/lib/util.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/lib/util.h b/src/lib/util.h index c8dcb29d6..36f8cec9e 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -128,4 +128,49 @@ vector_to_list (std::vector<T> v) return l; } +template <class T> +bool +deep_equals (std::list<boost::shared_ptr<T> > a, std::list<boost::shared_ptr<T> > b) +{ + if (a.size() != b.size()) { + return false; + } + + typename std::list<boost::shared_ptr<T> >::const_iterator i = a.begin(); + typename std::list<boost::shared_ptr<T> >::const_iterator j = b.begin(); + + while (i != a.end()) { + if (**i != **j) { + return false; + } + ++i; + ++j; + } + + return true; +} + +template <class T> +bool +deep_equals (std::list<T> a, std::list<T> b) +{ + if (a.size() != b.size()) { + return false; + } + + typename std::list<T>::const_iterator i = a.begin(); + typename std::list<T>::const_iterator j = b.begin(); + + while (i != a.end()) { + if (*i != *j) { + return false; + } + ++i; + ++j; + } + + return true; +} + #endif + |
