Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/CollectionsWTF.h

Issue 1880833002: Move to protocol::Vector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved hash to a String16STL.h (not yet in this repo) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CollectionsWTF_h 5 #ifndef CollectionsWTF_h
6 #define CollectionsWTF_h 6 #define CollectionsWTF_h
7 7
8 #include "wtf/Allocator.h" 8 #include "wtf/Allocator.h"
9 #include "wtf/HashMap.h" 9 #include "wtf/HashMap.h"
10 #include "wtf/PassOwnPtr.h" 10 #include "wtf/PassOwnPtr.h"
(...skipping 22 matching lines...) Expand all
33 T& operator[](size_t i) { return at(i); } 33 T& operator[](size_t i) { return at(i); }
34 const T& operator[](size_t i) const { return at(i); } 34 const T& operator[](size_t i) const { return at(i); }
35 T& at(size_t i) { return m_impl.at(i); } 35 T& at(size_t i) { return m_impl.at(i); }
36 const T& at(size_t i) const { return m_impl.at(i); } 36 const T& at(size_t i) const { return m_impl.at(i); }
37 T& last() { return m_impl.last(); } 37 T& last() { return m_impl.last(); }
38 const T& last() const { return m_impl.last(); } 38 const T& last() const { return m_impl.last(); }
39 void append(const T& t) { m_impl.append(t); } 39 void append(const T& t) { m_impl.append(t); }
40 void prepend(const T& t) { m_impl.prepend(t); } 40 void prepend(const T& t) { m_impl.prepend(t); }
41 void remove(size_t i) { m_impl.remove(i); } 41 void remove(size_t i) { m_impl.remove(i); }
42 void clear() { m_impl.clear(); } 42 void clear() { m_impl.clear(); }
43 void swap(Vector& other) { m_impl.swap(other.m_impl); } 43 void swap(Vector<T>& other) { m_impl.swap(other.m_impl); }
44 void removeLast() { m_impl.removeLast(); } 44 void removeLast() { m_impl.removeLast(); }
45 45
46 private: 46 private:
47 WTF::Vector<T> m_impl; 47 WTF::Vector<T> m_impl;
48 }; 48 };
49 49
50 template <typename T> 50 template <typename T>
51 class Vector<OwnPtr<T>> { 51 class Vector<OwnPtr<T>> {
52 WTF_MAKE_NONCOPYABLE(Vector); 52 WTF_MAKE_NONCOPYABLE(Vector);
53 public: 53 public:
54 Vector() { } 54 Vector() { }
55 Vector(size_t capacity) : m_impl(capacity) { } 55 Vector(size_t capacity) : m_impl(capacity) { }
56 Vector(Vector<OwnPtr<T>>&& other) : m_impl(std::move(other.m_impl)) { }
56 ~Vector() { } 57 ~Vector() { }
57 58
58 typedef OwnPtr<T>* iterator; 59 typedef OwnPtr<T>* iterator;
59 typedef const OwnPtr<T>* const_iterator; 60 typedef const OwnPtr<T>* const_iterator;
60 61
61 iterator begin() { return m_impl.begin(); } 62 iterator begin() { return m_impl.begin(); }
62 iterator end() { return m_impl.end(); } 63 iterator end() { return m_impl.end(); }
63 const_iterator begin() const { return m_impl.begin(); } 64 const_iterator begin() const { return m_impl.begin(); }
64 const_iterator end() const { return m_impl.end(); } 65 const_iterator end() const { return m_impl.end(); }
65 66
66 void resize(size_t s) { m_impl.resize(s); } 67 void resize(size_t s) { m_impl.resize(s); }
67 size_t size() const { return m_impl.size(); } 68 size_t size() const { return m_impl.size(); }
68 bool isEmpty() const { return m_impl.isEmpty(); } 69 bool isEmpty() const { return m_impl.isEmpty(); }
69 OwnPtr<T>& operator[](size_t i) { return m_impl.at(i); } 70 OwnPtr<T>& operator[](size_t i) { return m_impl.at(i); }
70 const OwnPtr<T>& operator[](size_t i) const { return m_impl.at(i); } 71 const OwnPtr<T>& operator[](size_t i) const { return m_impl.at(i); }
71 OwnPtr<T>& at(size_t i) { return m_impl.at(i); } 72 OwnPtr<T>& at(size_t i) { return m_impl.at(i); }
72 const OwnPtr<T>& at(size_t i) const { return m_impl.at(i); } 73 const OwnPtr<T>& at(size_t i) const { return m_impl.at(i); }
73 OwnPtr<T>& last() { return m_impl.last(); } 74 OwnPtr<T>& last() { return m_impl.last(); }
74 const OwnPtr<T>& last() const { return m_impl.last(); } 75 const OwnPtr<T>& last() const { return m_impl.last(); }
75 void append(PassOwnPtr<T> t) { m_impl.append(t); } 76 void append(PassOwnPtr<T> t) { m_impl.append(t); }
76 void prepend(PassOwnPtr<T> t) { m_impl.prepend(t); } 77 void prepend(PassOwnPtr<T> t) { m_impl.prepend(t); }
77 void remove(size_t i) { m_impl.remove(i); } 78 void remove(size_t i) { m_impl.remove(i); }
78 void clear() { m_impl.clear(); } 79 void clear() { m_impl.clear(); }
79 void swap(Vector& other) { m_impl.swap(other.m_impl); } 80 void swap(Vector<OwnPtr<T>>& other) { m_impl.swap(other.m_impl); }
81 void swap(Vector<OwnPtr<T>>&& other) { m_impl.swap(other.m_impl); }
80 void removeLast() { m_impl.removeLast(); } 82 void removeLast() { m_impl.removeLast(); }
81 83
82 private: 84 private:
83 WTF::Vector<OwnPtr<T>> m_impl; 85 WTF::Vector<OwnPtr<T>> m_impl;
84 }; 86 };
85 87
86 template <typename K, typename V, typename I> 88 template <typename K, typename V, typename I>
87 class HashMapIterator { 89 class HashMapIterator {
88 STACK_ALLOCATED(); 90 STACK_ALLOCATED();
89 public: 91 public:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 template <typename K> 184 template <typename K>
183 class HashSet : public protocol::HashMap<K, K> { 185 class HashSet : public protocol::HashMap<K, K> {
184 public: 186 public:
185 void add(const K& k) { this->set(k, k); } 187 void add(const K& k) { this->set(k, k); }
186 }; 188 };
187 189
188 } // namespace platform 190 } // namespace platform
189 } // namespace blink 191 } // namespace blink
190 192
191 #endif // !defined(CollectionsWTF_h) 193 #endif // !defined(CollectionsWTF_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698