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

Side by Side Diff: webrtc/base/buffer.h

Issue 2804673002: Add [c]begin() and [c]end() member functions to rtc::Buffer (Closed)
Patch Set: Remove redundant "this->" Created 3 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
« no previous file with comments | « no previous file | webrtc/base/buffer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 T& operator[](size_t index) { 172 T& operator[](size_t index) {
173 RTC_DCHECK_LT(index, size_); 173 RTC_DCHECK_LT(index, size_);
174 return data()[index]; 174 return data()[index];
175 } 175 }
176 176
177 T operator[](size_t index) const { 177 T operator[](size_t index) const {
178 RTC_DCHECK_LT(index, size_); 178 RTC_DCHECK_LT(index, size_);
179 return data()[index]; 179 return data()[index];
180 } 180 }
181 181
182 T* begin() { return data(); }
183 T* end() { return data() + size(); }
184 const T* begin() const { return data(); }
185 const T* end() const { return data() + size(); }
186 const T* cbegin() const { return data(); }
187 const T* cend() const { return data() + size(); }
188
182 // The SetData functions replace the contents of the buffer. They accept the 189 // The SetData functions replace the contents of the buffer. They accept the
183 // same input types as the constructors. 190 // same input types as the constructors.
184 template <typename U, 191 template <typename U,
185 typename std::enable_if< 192 typename std::enable_if<
186 internal::BufferCompat<T, U>::value>::type* = nullptr> 193 internal::BufferCompat<T, U>::value>::type* = nullptr>
187 void SetData(const U* data, size_t size) { 194 void SetData(const U* data, size_t size) {
188 RTC_DCHECK(IsConsistent()); 195 RTC_DCHECK(IsConsistent());
189 size_ = 0; 196 size_ = 0;
190 AppendData(data, size); 197 AppendData(data, size);
191 } 198 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 size_t capacity_; 372 size_t capacity_;
366 std::unique_ptr<T[]> data_; 373 std::unique_ptr<T[]> data_;
367 }; 374 };
368 375
369 // By far the most common sort of buffer. 376 // By far the most common sort of buffer.
370 using Buffer = BufferT<uint8_t>; 377 using Buffer = BufferT<uint8_t>;
371 378
372 } // namespace rtc 379 } // namespace rtc
373 380
374 #endif // WEBRTC_BASE_BUFFER_H_ 381 #endif // WEBRTC_BASE_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698