1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef MOZILLA_GFX_ARRAY_VIEW_H_
7 #define MOZILLA_GFX_ARRAY_VIEW_H_
11 /* This is similar to mfbt/Range.h but has implicit conversion
12 * from nsTArray and less bounds checking.
13 * For now, prefer Range over ArrayView */
21 MOZ_IMPLICIT
ArrayView(const nsTArray
<T
>& aData
)
22 : mData(aData
.Elements()), mLength(aData
.Length()) {}
23 ArrayView(const T
* aData
, const size_t aLength
)
24 : mData(aData
), mLength(aLength
) {}
25 const T
& operator[](const size_t aIdx
) const { return mData
[aIdx
]; }
26 size_t Length() const { return mLength
; }
27 const T
* Data() const { return mData
; }
35 } // namespace mozilla
37 #endif /* MOZILLA_GFX_ARRAY_VIEW_H_ */