template <typename T, typename Deleter = void>

class HeapArray

Defined at line 33 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

HeapArray

<T

> is a replacement for std::unique_ptr

<T

[]> that keeps track

of its size. It is intended to provide easy conversion to span

<T

> for most

usage, but it also provides bounds-checked indexing.

By default, elements in the array are either value-initialized (i.e. zeroed

for primitive types) when the array is created using the WithSize()

static method, or uninitialized when the array is created via the Uninit()

static method.

Public Methods

HeapArray<T, Deleter> WithSize (size_t size)

Allocates initialized memory capable of holding `size` elements. No memory

is allocated for zero-sized arrays.

Defined at line 48 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

HeapArray<T, Deleter> Uninit (size_t size)

Allocates uninitialized memory capable of holding `size` elements. T must

be trivially constructible and destructible. No memory is allocated for

zero-sized arrays.

Defined at line 60 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

HeapArray<T, Deleter> CopiedFrom (base::span<const T> that)

Defined at line 70 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

HeapArray<T, Deleter> FromOwningPointer (T * ptr, size_t size)

Constructs a HeapArray from an existing pointer, taking ownership of the

pointer.

# Safety

The pointer must be correctly aligned for type `T` and able to be deleted

through the `deleter_type`, which defaults to the `delete[]` operation. The

`ptr` must point to an array of at least `size` many elements. If these are

not met, then Undefined Behaviour can result.

# Checks

When the `size` is zero, the `ptr` must be null.

Defined at line 87 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

void HeapArray<T, Deleter> ()

Constructs an empty array and does not allocate any memory.

Defined at line 96 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

void HeapArray<T, Deleter> (const HeapArray<T, Deleter> & )

Move-only type since the memory is owned.

Defined at line 101 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

HeapArray<T, Deleter> & operator= (const HeapArray<T, Deleter> & )

Defined at line 102 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

void HeapArray<T, Deleter> (HeapArray<T, Deleter> && that)

Move-construction leaves the moved-from object empty and containing

no allocated memory.

Defined at line 106 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

HeapArray<T, Deleter> & operator= (HeapArray<T, Deleter> && that)

Move-assigment leaves the moved-from object empty and containing

no allocated memory.

Defined at line 111 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

void ~HeapArray<T, Deleter> ()

Defined at line 116 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

bool empty ()

Defined at line 118 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

size_t size ()

Defined at line 119 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

T * data ()

Prefer span-based methods below over data() where possible. The data()

method exists primarily to allow implicit constructions of spans.

Returns nullptr for a zero-sized (or moved-from) array.

Defined at line 124 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

const T * data ()

Defined at line 125 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

iterator begin ()

Defined at line 127 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

const_iterator begin ()

Defined at line 128 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

iterator end ()

Defined at line 132 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

const_iterator end ()

Defined at line 133 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

T & operator[] (size_t idx)

Defined at line 137 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

const T & operator[] (size_t idx)

Defined at line 140 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

base::span<T> as_span ()

Access the HeapArray via spans. Note that span

<T

> is implicilty

constructible from HeapArray

<T

>, so an explicit call to .as_span() is

most useful, say, when the compiler can't deduce a template

argument type.

Defined at line 148 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

base::span<const T> as_span ()

Defined at line 151 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

void copy_from (base::span<const T> other)

Convenience method to copy the contents of the entire array from a

span

<

>. Hard CHECK occurs in span

<

>::copy_from() if the HeapArray and

the span have different sizes.

Defined at line 158 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

base::span<T> subspan (size_t offset, size_t count)

Convenience methods to slice the vector into spans.

Returns a span over the HeapArray starting at `offset` of `count` elements.

If `count` is unspecified, all remaining elements are included. A CHECK()

occurs if any of the parameters results in an out-of-range position in

the HeapArray.

Defined at line 165 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

base::span<const T> subspan (size_t offset, size_t count)

Defined at line 169 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

base::span<T> first (size_t count)

Returns a span over the first `count` elements of the HeapArray. A CHECK()

occurs if the `count` is larger than size of the HeapArray.

Defined at line 177 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

base::span<const T> first (size_t count)

Defined at line 180 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

base::span<T> last (size_t count)

Returns a span over the last `count` elements of the HeapArray. A CHECK()

occurs if the `count` is larger than size of the HeapArray.

Defined at line 186 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

base::span<const T> last (size_t count)

Defined at line 189 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

base::span<T> leak ()

Leaks the memory in the HeapArray so that it will never be freed, and

consumes the HeapArray, returning an unowning span that points to the

memory.

Defined at line 196 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h

void DeleteLeakedData (void * ptr)

Delete the memory previously obtained from leak(). Argument is a pointer

rather than a span to facilitate use by callers that have lost track of

size information, as may happen when being passed through a C-style

function callback. The void* argument type makes its signature compatible

with typical void (*cb)(void*) C-style deletion callback.

Defined at line 207 of file ../../third_party/mini_chromium/src/base/containers/heap_array.h