fixed map and array list implemented as non - members

This commit is contained in:
Robin Müller 2020-09-29 16:41:14 +02:00
parent 9013ac240f
commit 4f3cfdcaaf
2 changed files with 33 additions and 11 deletions

View File

@ -133,19 +133,29 @@ public:
}
//SHOULDDO this should be implemented as non-member
bool operator==(const typename
ArrayList<T, count_t>::Iterator& other) const {
return (value == other.value);
}
//SHOULDDO this should be implemented as non-member
bool operator!=(const typename
ArrayList<T, count_t>::Iterator& other) const {
return !(*this == other);
}
// //SHOULDDO this should be implemented as non-member
// bool operator==(const typename
// ArrayList<T, count_t>::Iterator& other) const {
// return (value == other.value);
// }
//
// //SHOULDDO this should be implemented as non-member
// bool operator!=(const typename
// ArrayList<T, count_t>::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_ */

View File

@ -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]);
}