OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_BASE_CONTAINER_UTIL_H_ |
| 6 #define CC_BASE_CONTAINER_UTIL_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 // Removes the front element from the container and returns it. Note that this |
| 13 // currently only works with types that implement Pass(). |
| 14 // TODO(vmpstr): Use std::move instead of Pass when allowed. |
| 15 template <typename Container> |
| 16 typename Container::value_type PopFront(Container* container) { |
| 17 typename Container::value_type element = container->front().Pass(); |
| 18 container->pop_front(); |
| 19 return element; |
| 20 } |
| 21 |
| 22 // Removes the back element from the container and returns it. Note that this |
| 23 // currently only works with types that implement Pass(). |
| 24 // TODO(vmpstr): Use std::move instead of Pass when allowed. |
| 25 template <typename Container> |
| 26 typename Container::value_type PopBack(Container* container) { |
| 27 typename Container::value_type element = container->back().Pass(); |
| 28 container->pop_back(); |
| 29 return element; |
| 30 } |
| 31 |
| 32 } // namespace cc |
| 33 |
| 34 #endif // CC_BASE_CONTAINER_UTIL_H_ |
OLD | NEW |