Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
skia_private::AutoSTArray< kCountRequested, T > Class Template Reference

#include <SkTemplates.h>

Public Member Functions

 AutoSTArray (AutoSTArray &&)=delete
 
 AutoSTArray (const AutoSTArray &)=delete
 
AutoSTArrayoperator= (AutoSTArray &&)=delete
 
AutoSTArrayoperator= (const AutoSTArray &)=delete
 
 AutoSTArray ()
 
 AutoSTArray (int count)
 
 ~AutoSTArray ()
 
void reset (int count)
 
int count () const
 
Tget () const
 
Tbegin ()
 
const Tbegin () const
 
Tend ()
 
const Tend () const
 
Toperator[] (int index) const
 
const Tdata () const
 
Tdata ()
 
size_t size () const
 

Detailed Description

template<int kCountRequested, typename T>
class skia_private::AutoSTArray< kCountRequested, T >

Wraps AutoTArray, with room for kCountRequested elements preallocated.

Definition at line 169 of file SkTemplates.h.

Constructor & Destructor Documentation

◆ AutoSTArray() [1/4]

template<int kCountRequested, typename T >
skia_private::AutoSTArray< kCountRequested, T >::AutoSTArray ( AutoSTArray< kCountRequested, T > &&  )
delete

◆ AutoSTArray() [2/4]

template<int kCountRequested, typename T >
skia_private::AutoSTArray< kCountRequested, T >::AutoSTArray ( const AutoSTArray< kCountRequested, T > &  )
delete

◆ AutoSTArray() [3/4]

template<int kCountRequested, typename T >
skia_private::AutoSTArray< kCountRequested, T >::AutoSTArray ( )
inline

Initialize with no objects

Definition at line 177 of file SkTemplates.h.

177 {
178 fArray = nullptr;
179 fCount = 0;
180 }

◆ AutoSTArray() [4/4]

template<int kCountRequested, typename T >
skia_private::AutoSTArray< kCountRequested, T >::AutoSTArray ( int  count)
inline

Allocate count number of T elements

Definition at line 184 of file SkTemplates.h.

184 {
185 fArray = nullptr;
186 fCount = 0;
187 this->reset(count);
188 }
m reset()

◆ ~AutoSTArray()

template<int kCountRequested, typename T >
skia_private::AutoSTArray< kCountRequested, T >::~AutoSTArray ( )
inline

Definition at line 190 of file SkTemplates.h.

190 {
191 this->reset(0);
192 }

Member Function Documentation

◆ begin() [1/2]

template<int kCountRequested, typename T >
T * skia_private::AutoSTArray< kCountRequested, T >::begin ( )
inline

Definition at line 236 of file SkTemplates.h.

236{ return fArray; }

◆ begin() [2/2]

template<int kCountRequested, typename T >
const T * skia_private::AutoSTArray< kCountRequested, T >::begin ( ) const
inline

Definition at line 238 of file SkTemplates.h.

238{ return fArray; }

◆ count()

template<int kCountRequested, typename T >
int skia_private::AutoSTArray< kCountRequested, T >::count ( ) const
inline

Return the number of T elements in the array

Definition at line 230 of file SkTemplates.h.

230{ return fCount; }

◆ data() [1/2]

template<int kCountRequested, typename T >
T * skia_private::AutoSTArray< kCountRequested, T >::data ( )
inline

Definition at line 252 of file SkTemplates.h.

252{ return fArray; }

◆ data() [2/2]

template<int kCountRequested, typename T >
const T * skia_private::AutoSTArray< kCountRequested, T >::data ( ) const
inline

Aliases matching other types, like std::vector.

Definition at line 251 of file SkTemplates.h.

251{ return fArray; }

◆ end() [1/2]

template<int kCountRequested, typename T >
T * skia_private::AutoSTArray< kCountRequested, T >::end ( )
inline

Definition at line 240 of file SkTemplates.h.

240{ return fArray + fCount; }

◆ end() [2/2]

template<int kCountRequested, typename T >
const T * skia_private::AutoSTArray< kCountRequested, T >::end ( ) const
inline

Definition at line 242 of file SkTemplates.h.

242{ return fArray + fCount; }

◆ get()

template<int kCountRequested, typename T >
T * skia_private::AutoSTArray< kCountRequested, T >::get ( ) const
inline

Return the array of T elements. Will be NULL if count == 0

Definition at line 234 of file SkTemplates.h.

234{ return fArray; }

◆ operator=() [1/2]

template<int kCountRequested, typename T >
AutoSTArray & skia_private::AutoSTArray< kCountRequested, T >::operator= ( AutoSTArray< kCountRequested, T > &&  )
delete

◆ operator=() [2/2]

template<int kCountRequested, typename T >
AutoSTArray & skia_private::AutoSTArray< kCountRequested, T >::operator= ( const AutoSTArray< kCountRequested, T > &  )
delete

◆ operator[]()

template<int kCountRequested, typename T >
T & skia_private::AutoSTArray< kCountRequested, T >::operator[] ( int  index) const
inline

Return the nth element in the array

Definition at line 246 of file SkTemplates.h.

246 {
247 return fArray[sk_collection_check_bounds(index, fCount)];
248 }
SK_API T sk_collection_check_bounds(T i, T size)
Definition SkAssert.h:143

◆ reset()

template<int kCountRequested, typename T >
void skia_private::AutoSTArray< kCountRequested, T >::reset ( int  count)
inline

Destroys previous objects in the array and default constructs count number of objects

Definition at line 195 of file SkTemplates.h.

195 {
196 T* start = fArray;
197 T* iter = start + fCount;
198 while (iter > start) {
199 (--iter)->~T();
200 }
201
202 SkASSERT(count >= 0);
203 if (fCount != count) {
204 if (fCount > kCount) {
205 // 'fArray' was allocated last time so free it now
206 SkASSERT((T*) fStorage != fArray);
207 sk_free(fArray);
208 }
209
210 if (count > kCount) {
211 fArray = (T*) sk_malloc_throw(count, sizeof(T));
212 } else if (count > 0) {
213 fArray = (T*) fStorage;
214 } else {
215 fArray = nullptr;
216 }
217
218 fCount = count;
219 }
220
221 iter = fArray;
222 T* stop = fArray + count;
223 while (iter < stop) {
224 new (iter++) T;
225 }
226 }
#define SkASSERT(cond)
Definition SkAssert.h:116
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
Definition SkMalloc.h:67
#define T

◆ size()

template<int kCountRequested, typename T >
size_t skia_private::AutoSTArray< kCountRequested, T >::size ( ) const
inline

Definition at line 253 of file SkTemplates.h.

253{ return fCount; }

The documentation for this class was generated from the following file: