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

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

Issue 1418423010: Pass audio to AudioEncoder::Encode() in an ArrayView (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month 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 2015 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2015 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 T& operator[](size_t idx) const { 65 T& operator[](size_t idx) const {
66 RTC_DCHECK_LT(idx, size_); 66 RTC_DCHECK_LT(idx, size_);
67 RTC_DCHECK(data_); // Follows from size_ > idx and the class invariant. 67 RTC_DCHECK(data_); // Follows from size_ > idx and the class invariant.
68 return data_[idx]; 68 return data_[idx];
69 } 69 }
70 T* begin() const { return data_; } 70 T* begin() const { return data_; }
71 T* end() const { return data_ + size_; } 71 T* end() const { return data_ + size_; }
72 const T* cbegin() const { return data_; } 72 const T* cbegin() const { return data_; }
73 const T* cend() const { return data_ + size_; } 73 const T* cend() const { return data_ + size_; }
74 74
75 // An ArrayView is false iff it's empty.
76 explicit operator bool() const { return size_ > 0; }
77
78 // Comparing two ArrayViews compares their (pointer,size) pairs; it does
79 // *not* dereference the pointers.
80 friend bool operator==(const ArrayView& a, const ArrayView& b) {
81 return a.data_ == b.data_ && a.size_ == b.size_;
82 }
83 friend bool operator!=(const ArrayView& a, const ArrayView& b) {
84 return !(a == b);
85 }
86
75 private: 87 private:
76 // Invariant: !data_ iff size_ == 0. 88 // Invariant: !data_ iff size_ == 0.
77 void CheckInvariant() const { RTC_DCHECK_EQ(!data_, size_ == 0); } 89 void CheckInvariant() const { RTC_DCHECK_EQ(!data_, size_ == 0); }
78 T* data_; 90 T* data_;
79 size_t size_; 91 size_t size_;
80 }; 92 };
81 93
82 } // namespace rtc 94 } // namespace rtc
83 95
84 #endif // WEBRTC_BASE_ARRAY_VIEW_H_ 96 #endif // WEBRTC_BASE_ARRAY_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/array_view_unittest.cc » ('j') | webrtc/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698