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

Side by Side Diff: third_party/WebKit/Source/wtf/Deque.h

Issue 2746763009: Migrate WTF::Deque::prepend() to ::push_front() (Closed)
Patch Set: Created 3 years, 9 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 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 RELEASE_ASSERT(i < size()); 119 RELEASE_ASSERT(i < size());
120 size_t right = m_buffer.capacity() - m_start; 120 size_t right = m_buffer.capacity() - m_start;
121 return i < right ? m_buffer.buffer()[m_start + i] 121 return i < right ? m_buffer.buffer()[m_start + i]
122 : m_buffer.buffer()[i - right]; 122 : m_buffer.buffer()[i - right];
123 } 123 }
124 124
125 T& operator[](size_t i) { return at(i); } 125 T& operator[](size_t i) { return at(i); }
126 const T& operator[](size_t i) const { return at(i); } 126 const T& operator[](size_t i) const { return at(i); }
127 127
128 template <typename U> 128 template <typename U>
129 void prepend(U&&); 129 void push_front(U&&);
130 void erase(iterator&); 130 void erase(iterator&);
131 void erase(const_iterator&); 131 void erase(const_iterator&);
132 132
133 // STL compatibility. 133 // STL compatibility.
134 template <typename U> 134 template <typename U>
135 void push_back(U&&); 135 void push_back(U&&);
136 template <typename U>
137 void push_front(U&& u) {
138 prepend(std::forward<U>(u));
139 }
140 void pop_back(); 136 void pop_back();
141 void pop_front(); 137 void pop_front();
142 bool empty() const { return isEmpty(); } 138 bool empty() const { return isEmpty(); }
143 template <typename... Args> 139 template <typename... Args>
144 void emplace_back(Args&&...); 140 void emplace_back(Args&&...);
145 template <typename... Args> 141 template <typename... Args>
146 void emplace_front(Args&&...); 142 void emplace_front(Args&&...);
147 143
148 void clear(); 144 void clear();
149 145
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 T* newElement = &m_buffer.buffer()[m_end]; 495 T* newElement = &m_buffer.buffer()[m_end];
500 if (m_end == m_buffer.capacity() - 1) 496 if (m_end == m_buffer.capacity() - 1)
501 m_end = 0; 497 m_end = 0;
502 else 498 else
503 ++m_end; 499 ++m_end;
504 new (NotNull, newElement) T(std::forward<U>(value)); 500 new (NotNull, newElement) T(std::forward<U>(value));
505 } 501 }
506 502
507 template <typename T, size_t inlineCapacity, typename Allocator> 503 template <typename T, size_t inlineCapacity, typename Allocator>
508 template <typename U> 504 template <typename U>
509 inline void Deque<T, inlineCapacity, Allocator>::prepend(U&& value) { 505 inline void Deque<T, inlineCapacity, Allocator>::push_front(U&& value) {
510 expandCapacityIfNeeded(); 506 expandCapacityIfNeeded();
511 if (!m_start) 507 if (!m_start)
512 m_start = m_buffer.capacity() - 1; 508 m_start = m_buffer.capacity() - 1;
513 else 509 else
514 --m_start; 510 --m_start;
515 new (NotNull, &m_buffer.buffer()[m_start]) T(std::forward<U>(value)); 511 new (NotNull, &m_buffer.buffer()[m_start]) T(std::forward<U>(value));
516 } 512 }
517 513
518 template <typename T, size_t inlineCapacity, typename Allocator> 514 template <typename T, size_t inlineCapacity, typename Allocator>
519 template <typename... Args> 515 template <typename... Args>
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 inline void swap(Deque<T, inlineCapacity, Allocator>& a, 697 inline void swap(Deque<T, inlineCapacity, Allocator>& a,
702 Deque<T, inlineCapacity, Allocator>& b) { 698 Deque<T, inlineCapacity, Allocator>& b) {
703 a.swap(b); 699 a.swap(b);
704 } 700 }
705 701
706 } // namespace WTF 702 } // namespace WTF
707 703
708 using WTF::Deque; 704 using WTF::Deque;
709 705
710 #endif // WTF_Deque_h 706 #endif // WTF_Deque_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/SegmentedString.cpp ('k') | third_party/WebKit/Source/wtf/DequeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698