| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CONTENT_BROWSER_INDEXED_DB_LIST_SET_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_LIST_SET_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_LIST_SET_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_LIST_SET_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class list_set { | 26 class list_set { |
| 27 public: | 27 public: |
| 28 list_set() {} | 28 list_set() {} |
| 29 list_set(const list_set<T>& other) : list_(other.list_), set_(other.set_) {} | 29 list_set(const list_set<T>& other) : list_(other.list_), set_(other.set_) {} |
| 30 list_set& operator=(const list_set<T>& other) { | 30 list_set& operator=(const list_set<T>& other) { |
| 31 list_ = other.list_; | 31 list_ = other.list_; |
| 32 set_ = other.set_; | 32 set_ = other.set_; |
| 33 return *this; | 33 return *this; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void insert_front(const T& elem) { |
| 37 if (set_.find(elem) != set_.end()) |
| 38 return; |
| 39 set_.insert(elem); |
| 40 list_.push_front(elem); |
| 41 } |
| 42 |
| 36 void insert(const T& elem) { | 43 void insert(const T& elem) { |
| 37 if (set_.find(elem) != set_.end()) | 44 if (set_.find(elem) != set_.end()) |
| 38 return; | 45 return; |
| 39 set_.insert(elem); | 46 set_.insert(elem); |
| 40 list_.push_back(elem); | 47 list_.push_back(elem); |
| 41 } | 48 } |
| 42 | 49 |
| 43 void erase(const T& elem) { | 50 void erase(const T& elem) { |
| 44 if (set_.find(elem) == set_.end()) | 51 if (set_.find(elem) == set_.end()) |
| 45 return; | 52 return; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 std::set<T> set_; | 160 std::set<T> set_; |
| 154 }; | 161 }; |
| 155 | 162 |
| 156 // Prevent instantiation of list_set<std::unique_ptr<T>> as the current | 163 // Prevent instantiation of list_set<std::unique_ptr<T>> as the current |
| 157 // implementation would fail. | 164 // implementation would fail. |
| 158 // TODO(jsbell): Support scoped_ptr through specialization. | 165 // TODO(jsbell): Support scoped_ptr through specialization. |
| 159 template <typename T> | 166 template <typename T> |
| 160 class list_set<std::unique_ptr<T>>; | 167 class list_set<std::unique_ptr<T>>; |
| 161 | 168 |
| 162 #endif // CONTENT_BROWSER_INDEXED_DB_LIST_SET_H_ | 169 #endif // CONTENT_BROWSER_INDEXED_DB_LIST_SET_H_ |
| OLD | NEW |