From 4f3cfdcaaf57a790ae7b8cf874c76252f20ceb6d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 16:41:14 +0200 Subject: [PATCH] fixed map and array list implemented as non - members --- container/ArrayList.h | 34 +++++++++++++++++++++++----------- container/FixedMap.h | 10 ++++++++++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/container/ArrayList.h b/container/ArrayList.h index 426e02b3..16318569 100644 --- a/container/ArrayList.h +++ b/container/ArrayList.h @@ -133,19 +133,29 @@ public: } - //SHOULDDO this should be implemented as non-member - bool operator==(const typename - ArrayList::Iterator& other) const { - return (value == other.value); - } - - //SHOULDDO this should be implemented as non-member - bool operator!=(const typename - ArrayList::Iterator& other) const { - return !(*this == other); - } +// //SHOULDDO this should be implemented as non-member +// bool operator==(const typename +// ArrayList::Iterator& other) const { +// return (value == other.value); +// } +// +// //SHOULDDO this should be implemented as non-member +// bool operator!=(const typename +// ArrayList::Iterator& other) const { +// return !(*this == other); +// } }; + friend bool operator==(const ArrayList::Iterator& lhs, + const ArrayList::Iterator& rhs) { + return (lhs.value == rhs.value); + } + + friend bool operator!=(const ArrayList::Iterator& lhs, + const ArrayList::Iterator& rhs) { + return not (lhs.value == rhs.value); + } + /** * Iterator pointing to the first stored elmement * @@ -251,4 +261,6 @@ protected: bool allocated; }; + + #endif /* FSFW_CONTAINER_ARRAYLIST_H_ */ diff --git a/container/FixedMap.h b/container/FixedMap.h index e5fbb3be..1e36b1bc 100644 --- a/container/FixedMap.h +++ b/container/FixedMap.h @@ -61,6 +61,16 @@ public: } }; + friend bool operator==(const typename FixedMap::Iterator& lhs, + const typename FixedMap::Iterator& rhs) { + return (lhs.value == rhs.value); + } + + friend bool operator!=(const typename FixedMap::Iterator& lhs, + const typename FixedMap::Iterator& rhs) { + return not (lhs.value == rhs.value); + } + Iterator begin() const { return Iterator(&theMap[0]); }