Changeset 6d8a63a in mainline


Ignore:
Timestamp:
2018-07-05T21:41:21Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
de53138
Parents:
f9ce7cd
git-author:
Dzejrou <dzejrou@…> (2018-04-17 20:16:52)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:21)
Message:

cpp: added relational operators for deque

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/impl/deque.hpp

    rf9ce7cd r6d8a63a  
    11461146    bool operator==(const deque<T, Allocator>& lhs, const deque<T, Allocator>& rhs)
    11471147    {
    1148         // TODO: implement
    1149         return false;
     1148        if (lhs.size() != rhs.size())
     1149            return false;
     1150
     1151        for (decltype(lhs.size()) i = 0; i < lhs.size(); ++i)
     1152        {
     1153            if (lhs[i] != rhs[i])
     1154                return false;
     1155        }
     1156
     1157        return true;
    11501158    }
    11511159
     
    11531161    bool operator<(const deque<T, Allocator>& lhs, const deque<T, Allocator>& rhs)
    11541162    {
    1155         // TODO: implement
    1156         return false;
     1163        auto min_size = min(lhs.size(), rhs.size());
     1164        for (decltype(lhs.size()) i = 0; i < min_size; ++i)
     1165        {
     1166            if (lhs[i] >= rhs[i])
     1167                return false;
     1168        }
     1169
     1170        if (lhs.size() == rhs.size())
     1171            return true;
     1172        else
     1173            return lhs.size() < rhs.size();
    11571174    }
    11581175
     
    11601177    bool operator!=(const deque<T, Allocator>& lhs, const deque<T, Allocator>& rhs)
    11611178    {
    1162         // TODO: implement
    1163         return false;
     1179        return !(lhs == rhs);
    11641180    }
    11651181
     
    11671183    bool operator>(const deque<T, Allocator>& lhs, const deque<T, Allocator>& rhs)
    11681184    {
    1169         // TODO: implement
    1170         return false;
     1185        return rhs < lhs;
    11711186    }
    11721187
     
    11741189    bool operator<=(const deque<T, Allocator>& lhs, const deque<T, Allocator>& rhs)
    11751190    {
    1176         // TODO: implement
    1177         return false;
     1191        return !(rhs < lhs);
    11781192    }
    11791193
     
    11811195    bool operator>=(const deque<T, Allocator>& lhs, const deque<T, Allocator>& rhs)
    11821196    {
    1183         // TODO: implement
    1184         return false;
     1197        return !(lhs < rhs);
    11851198    }
    11861199
Note: See TracChangeset for help on using the changeset viewer.