diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-07-09 19:21:51 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-07-09 19:21:51 -0400 |
commit | 65ff135ec54ef6d2b2286e45c95256a7e08f3b25 (patch) | |
tree | ea06fc0190d5e0eaab2cdc0b2f39660c6c3dd775 | |
parent | 6fc09cc902bcaec81d6884f61360448fd3fd3b03 (diff) |
Use front() over index access.
-rw-r--r-- | merge-sort.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/merge-sort.cpp b/merge-sort.cpp index e7647a0..5bbe1fe 100644 --- a/merge-sort.cpp +++ b/merge-sort.cpp @@ -15,25 +15,25 @@ void merge(list_t& lst, list_t left, list_t right) { if (!left.empty() && !right.empty()) { - if (left[0] <= right[0]) + if (left.front() <= right.front()) { - res.push_back(left[0]); + res.push_back(left.front()); left.pop_front(); } else { - res.push_back(right[0]); + res.push_back(right.front()); right.pop_front(); } } else if (!left.empty()) { - res.push_back(left[0]); + res.push_back(left.front()); left.pop_front(); } else if (!right.empty()) { - res.push_back(right[0]); + res.push_back(right.front()); right.pop_front(); } } |