Flutter Engine
The Flutter Engine
|
#include <SkTBlockList.h>
Public Types | |
using | Iter = BlockIndexIterator< T &, true, false, &First, &Last, &Increment, &GetItem > |
using | CIter = BlockIndexIterator< const T &, true, true, &First, &Last, &Increment, &GetItem > |
using | RIter = BlockIndexIterator< T &, false, false, &Last, &First, &Decrement, &GetItem > |
using | CRIter = BlockIndexIterator< const T &, false, true, &Last, &First, &Decrement, &GetItem > |
Public Member Functions | |
SkTBlockList () | |
SkTBlockList (SkBlockAllocator::GrowthPolicy policy) | |
SkTBlockList (int itemsPerBlock, SkBlockAllocator::GrowthPolicy policy=SkBlockAllocator::GrowthPolicy::kFixed) | |
~SkTBlockList () | |
T & | push_back () |
T & | push_back (const T &t) |
T & | push_back (T &&t) |
template<typename... Args> | |
T & | emplace_back (Args &&... args) |
template<int SI> | |
void | concat (SkTBlockList< T, SI > &&other) |
void | reserve (int n) |
void | pop_back () |
void | reset () |
int | count () const |
bool | empty () const |
T & | front () |
const T & | front () const |
T & | back () |
const T & | back () const |
T & | item (int i) |
const T & | item (int i) const |
Iter | items () |
CIter | items () const |
RIter | ritems () |
CRIter | ritems () const |
template<int SI2> | |
void | concat (SkTBlockList< T, SI2 > &&other) |
Friends | |
template<typename S , int N> | |
class | SkTBlockList |
class | TBlockListTestAccess |
SkTBlockList manages dynamic storage for instances of T, reserving fixed blocks such that allocation is amortized across every N instances. In this way it is a hybrid of an array-based vector and a linked-list. T can be any type and non-trivial destructors are automatically invoked when the SkTBlockList is destructed. The addresses of instances are guaranteed not to move except when a list is concatenated to another.
The collection supports storing a templated number of elements inline before heap-allocated blocks are made to hold additional instances. By default, the heap blocks are sized to hold the same number of items as the inline block. A common pattern is to have the inline size hold only a small number of items for the common case and then allocate larger blocks when needed.
If the size of a collection is N, and its block size is B, the complexity of the common operations are:
These characteristics make it well suited for allocating items in a LIFO ordering, or otherwise acting as a stack, or simply using it as a typed allocator.
Definition at line 56 of file SkTBlockList.h.
using SkTBlockList< T, StartingItems >::CIter = BlockIndexIterator<const T&, true, true, &First, &Last, &Increment, &GetItem> |
Definition at line 288 of file SkTBlockList.h.
using SkTBlockList< T, StartingItems >::CRIter = BlockIndexIterator<const T&, false, true, &Last, &First, &Decrement, &GetItem> |
Definition at line 290 of file SkTBlockList.h.
using SkTBlockList< T, StartingItems >::Iter = BlockIndexIterator<T&, true, false, &First, &Last, &Increment, &GetItem> |
Definition at line 287 of file SkTBlockList.h.
using SkTBlockList< T, StartingItems >::RIter = BlockIndexIterator<T&, false, false, &Last, &First, &Decrement, &GetItem> |
Definition at line 289 of file SkTBlockList.h.
|
inline |
Create an list that defaults to using StartingItems as heap increment and the kFixed growth policy (e.g. all allocations will match StartingItems).
Definition at line 62 of file SkTBlockList.h.
|
inlineexplicit |
Create an list that defaults to using StartingItems as the heap increment, but with the defined growth policy.
Definition at line 68 of file SkTBlockList.h.
|
inlineexplicit |
Create an list.
itemsPerBlock | the number of items to allocate at once |
policy | the growth policy for subsequent blocks of items |
Definition at line 77 of file SkTBlockList.h.
|
inline |
Definition at line 83 of file SkTBlockList.h.
|
inline |
Access last item, only call if count() != 0
Definition at line 204 of file SkTBlockList.h.
|
inline |
Definition at line 208 of file SkTBlockList.h.
void SkTBlockList< T, StartingItems >::concat | ( | SkTBlockList< T, SI > && | other | ) |
Move all items from 'other' to the end of this collection. When this returns, 'other' will be empty. Items in 'other' may be moved as part of compacting the pre-allocated start of 'other' into this list (using T's move constructor or memcpy if T is trivially copyable), but this is O(StartingItems) and not O(N). All other items are concatenated in O(1).
void SkTBlockList< T, StartingItems >::concat | ( | SkTBlockList< T, SI2 > && | other | ) |
Definition at line 307 of file SkTBlockList.h.
|
inline |
Returns the item count.
Definition at line 167 of file SkTBlockList.h.
|
inline |
Definition at line 101 of file SkTBlockList.h.
|
inline |
|
inline |
Access first item, only call if count() != 0
Definition at line 190 of file SkTBlockList.h.
|
inline |
|
inline |
Access item by index. Not an operator[] since it should not be considered constant time. Use for-range loops by calling items() or ritems() instead to access all added items in order
Definition at line 217 of file SkTBlockList.h.
|
inline |
Definition at line 237 of file SkTBlockList.h.
|
inline |
Iterate over all items in allocation order (oldest to newest) using a for-range loop:
for (auto&& T : this->items()) {}
Definition at line 297 of file SkTBlockList.h.
|
inline |
Definition at line 298 of file SkTBlockList.h.
|
inline |
Remove the last item, only call if count() != 0
Definition at line 130 of file SkTBlockList.h.
|
inline |
|
inline |
Definition at line 93 of file SkTBlockList.h.
|
inline |
Definition at line 96 of file SkTBlockList.h.
|
inline |
Allocate, if needed, space to hold N more Ts before another malloc will occur.
Definition at line 117 of file SkTBlockList.h.
|
inline |
Removes all added items.
Definition at line 153 of file SkTBlockList.h.
|
inline |
Definition at line 301 of file SkTBlockList.h.
|
inline |
Definition at line 302 of file SkTBlockList.h.
|
friend |
Definition at line 244 of file SkTBlockList.h.
|
friend |
Definition at line 245 of file SkTBlockList.h.