summaryrefslogtreecommitdiff
path: root/vector.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'vector.hpp')
-rw-r--r--vector.hpp58
1 files changed, 51 insertions, 7 deletions
diff --git a/vector.hpp b/vector.hpp
index b43d994..b0c0d52 100644
--- a/vector.hpp
+++ b/vector.hpp
@@ -288,23 +288,67 @@ namespace ft {
};
template<class T, class Alloc>
void swap(vector<T,Alloc>& lhs,
- vector<T,Alloc>& rhs);
+ vector<T,Alloc>& rhs)
+ {
+ lhs.swap(rhs);
+ }
+
template<class T, class Alloc>
bool operator==(const vector<T,Alloc>& lhs,
- const vector<T,Alloc>& rhs);
+ const vector<T,Alloc>& rhs)
+ {
+ if (lhs.size() != rhs.size())
+ return false;
+ for (typename vector<T,Alloc>::size_type i = 0; i < lhs.size(); i++)
+ if (lhs[i] != rhs[i])
+ return false;
+ return true;
+ }
+
template<class T, class Alloc>
bool operator!=(const vector<T,Alloc>& lhs,
- const vector<T,Alloc>& rhs);
+ const vector<T,Alloc>& rhs)
+ {
+ return !(lhs == rhs);
+ }
+
template<class T, class Alloc>
bool operator<(const vector<T,Alloc>& lhs,
- const vector<T,Alloc>& rhs);
+ const vector<T,Alloc>& rhs)
+ {
+ const typename vector<T,Alloc>::size_type end
+ (lhs.size() < rhs.size() ? lhs.size() : rhs.size());
+ for (typename vector<T,Alloc>::size_type i = 0; i < end; i++) {
+ if (lhs[i] < rhs[i])
+ return true;
+ }
+ return lhs.size() < rhs.size();
+ }
+
template<class T, class Alloc>
bool operator<=(const vector<T,Alloc>& lhs,
- const vector<T,Alloc>& rhs);
+ const vector<T,Alloc>& rhs)
+ {
+ return !(lhs > rhs);
+ }
+
template<class T, class Alloc>
bool operator>(const vector<T,Alloc>& lhs,
- const vector<T,Alloc>& rhs);
+ const vector<T,Alloc>& rhs)
+ {
+ const typename vector<T,Alloc>::size_type end
+ (lhs.size() < rhs.size() ? lhs.size() : rhs.size());
+ for (typename vector<T,Alloc>::size_type i = 0; i < end; i++) {
+ if (lhs[i] > rhs[i])
+ return true;
+ }
+ return lhs.size() > rhs.size();
+ }
+
template<class T, class Alloc>
bool operator>=(const vector<T,Alloc>& lhs,
- const vector<T,Alloc>& rhs);
+ const vector<T,Alloc>& rhs)
+ {
+ return !(lhs < rhs);
+ }
}