SkTArray: behave a little more like std::vector
Change-Id: Ia29b5dbda707bfd993cc40396a7fc2127d7f1952
Reviewed-on: https://skia-review.googlesource.com/c/163785
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/include/private/SkTArray.h b/include/private/SkTArray.h
index 75cd001..a18d6e0 100644
--- a/include/private/SkTArray.h
+++ b/include/private/SkTArray.h
@@ -37,12 +37,12 @@
/**
* Copies one array to another. The new array will be heap allocated.
*/
- explicit SkTArray(const SkTArray& that) {
+ SkTArray(const SkTArray& that) {
this->init(that.fCount);
this->copy(that.fItemArray);
}
- explicit SkTArray(SkTArray&& that) {
+ SkTArray(SkTArray&& that) {
// TODO: If 'that' owns its memory why don't we just steal the pointer?
this->init(that.fCount);
that.move(fMemArray);
@@ -327,6 +327,10 @@
const T* end() const {
return fItemArray ? fItemArray + fCount : nullptr;
}
+ T* data() { return fItemArray; }
+ const T* data() const { return fItemArray; }
+ size_t size() const { return (size_t)fCount; }
+ void resize(size_t count) { this->resize_back((int)count); }
/**
* Get the i^th element.