OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_BASE_CONTAINER_UTIL_H_ | 5 #ifndef CC_BASE_CONTAINER_UTIL_H_ |
6 #define CC_BASE_CONTAINER_UTIL_H_ | 6 #define CC_BASE_CONTAINER_UTIL_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | |
9 | 8 |
10 namespace cc { | 9 namespace cc { |
11 | 10 |
12 // Removes the front element from the container and returns it. | 11 // Removes the front element from the container and returns it. |
13 template <typename Container> | 12 template <typename Container> |
14 typename Container::value_type PopFront(Container* container) { | 13 typename Container::value_type PopFront(Container* container) { |
15 typename Container::value_type element = std::move(container->front()); | 14 typename Container::value_type element = std::move(container->front()); |
16 container->pop_front(); | 15 container->pop_front(); |
17 return element; | 16 return element; |
18 } | 17 } |
19 | 18 |
20 // Removes the back element from the container and returns it. | 19 // Removes the back element from the container and returns it. |
21 template <typename Container> | 20 template <typename Container> |
22 typename Container::value_type PopBack(Container* container) { | 21 typename Container::value_type PopBack(Container* container) { |
23 typename Container::value_type element = std::move(container->back()); | 22 typename Container::value_type element = std::move(container->back()); |
24 container->pop_back(); | 23 container->pop_back(); |
25 return element; | 24 return element; |
26 } | 25 } |
27 | 26 |
28 } // namespace cc | 27 } // namespace cc |
29 | 28 |
30 #endif // CC_BASE_CONTAINER_UTIL_H_ | 29 #endif // CC_BASE_CONTAINER_UTIL_H_ |
OLD | NEW |