ready for surrender

This commit is contained in:
hugogogo
2022-06-27 15:55:18 +02:00
parent 6617d6cdf5
commit 26436c8d8a
11 changed files with 217 additions and 143 deletions

View File

@@ -6,34 +6,15 @@ namespace ft {
template <class InputIt1, class InputIt2>
bool lexicographical_compare
( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) {
( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2 ) {
while (first1 != last1)
{
if (first2 == last2 || *first2 < *first1)
return false;
else if (*first1 < *first2)
for (; first1 != last1; first1++, first2++) {
if (*first1 < *first2)
return true;
++first1;
++first2;
}
return (first2 != last2);
}
template <class InputIt1, class InputIt2, class Compare>
bool lexicographical_compare
( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp) {
while (first1 != last1)
{
if (first2 == last2 || comp(*first2, *first1))
if (*first2 < *first1)
return false;
else if (comp(*first1, *first2))
return true;
++first1;
++first2;
}
return (first2 != last2);
return (first1 == last1 && first2 != last2);
}
} // namespace ft

View File

@@ -9,8 +9,8 @@ namespace ft {
template <
typename T,
typename Container = ft::vector<T>
> class stack
{
> class stack {
public:
typedef Container container_type;
typedef typename Container::value_type value_type;
@@ -22,7 +22,6 @@ public:
************/
// constructors ------------------------------
explicit stack(const container_type& cont = Container()) : c(cont) {}
explicit stack(stack const &other): c(other.c) {}
/**********************
@@ -55,7 +54,7 @@ public:
friend bool operator>=(const stack<T2,C2>& lhs, const stack<T2,C2>& rhs);
protected:
Container c;
container_type c;
};