template <typename T>
class RepeatedPtrField
Defined at line 930 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
RepeatedPtrField is like RepeatedField, but used for repeated strings or
Messages.
Public Methods
void RepeatedPtrField<T> (internal::InternalVisibility , Arena * arena)
Arena enabled constructors: for internal use only.
Defined at line 970 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void RepeatedPtrField<T> (internal::InternalVisibility , Arena * arena, const RepeatedPtrField<Element> & rhs)
Defined at line 972 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void RepeatedPtrField<T> (const RepeatedPtrField<Element> & rhs)
Defined at line 984 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void RepeatedPtrField<T> (RepeatedPtrField<Element> && rhs)
Defined at line 989 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void Add (const Element & value)
Copying to the end of this RepeatedPtrField is slowest of all; it can't
reliably copy-construct to the last element of this RepeatedPtrField, for
example (unlike std::vector).
We currently block this API. The right way to add to the end is to call
Add() and modify the element it points to.
If you must add an existing value, call `*Add() = value;`
Defined at line 1021 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_reference operator[] (int index)
Defined at line 1028 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
reference operator[] (int index)
Defined at line 1031 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
reverse_iterator rbegin ()
Defined at line 1093 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_reverse_iterator rbegin ()
Defined at line 1096 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
reverse_iterator rend ()
Defined at line 1099 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_reverse_iterator rend ()
Defined at line 1102 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
int SpaceUsedExcludingSelf ()
Defined at line 1115 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void InternalSwap (RepeatedPtrField<Element> *__restrict other)
For internal use only.
This is public due to it being called by generated code.
Defined at line 1224 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void RepeatedPtrField<T> ()
-------------------------------------------------------------------
Defined at line 1256 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void RepeatedPtrField<T> (Arena * arena)
TODO: make constructor private
Defined at line 1262 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
template <typename Iter, typename = typename std::enable_if<std::is_constructible<
Element, decltype(*std::declval<Iter>())>::value>::type>
void RepeatedPtrField<T> (Iter begin, Iter end)
Defined at line 1278 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
RepeatedPtrField<Element> & operator= (const RepeatedPtrField<Element> & other)
Defined at line 1300 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
RepeatedPtrField<Element> & operator= (RepeatedPtrField<Element> && other)
Defined at line 1320 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void ~RepeatedPtrField<T> ()
Defined at line 1285 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
bool empty ()
Defined at line 1335 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
int size ()
Defined at line 1340 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_reference Get (int index)
Defined at line 1345 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
pointer Mutable (int index)
Defined at line 1364 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
pointer Add ()
Unlike std::vector, adding an element to a RepeatedPtrField doesn't always
make a new element; it might re-use an element left over from when the
field was Clear()'d or resize()'d smaller. For this reason, Add() is the
fastest API for adding a new element.
Defined at line 1370 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void Add (Element && value)
`Add(std::move(value));` is equivalent to `*Add() = std::move(value);`
It will either move-construct to the end of this field, or swap value
with the new-or-recycled element at the end of this field. Note that
this operation is very slow if this RepeatedPtrField is not on the
same Arena, if any, as `value`.
Defined at line 1375 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
template <typename Iter>
void Add (Iter begin, Iter end)
Append elements in the range [begin, end) after reserving
the appropriate number of elements.
Defined at line 1380 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_reference at (int index)
Defined at line 1351 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
reference at (int index)
Defined at line 1357 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void RemoveLast ()
Removes the last element in the array.
Ownership of the element is retained by the array.
Defined at line 1394 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void DeleteSubrange (int start, int num)
Deletes elements with indices in the range [start .. start+num-1].
Caution: moves all elements with indices [start+num .. ].
Calling this routine inside a loop can cause quadratic behavior.
Defined at line 1399 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void Clear ()
Defined at line 1469 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void MergeFrom (const RepeatedPtrField<Element> & other)
Appends the elements from `other` after this instance.
The end result length will be `other.size() + this->size()`.
Defined at line 1474 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void CopyFrom (const RepeatedPtrField<Element> & other)
Replaces the contents with a copy of the elements from `other`.
Defined at line 1481 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
template <typename Iter>
void Assign (Iter begin, Iter end)
Replaces the contents with RepeatedPtrField(begin, end).
Defined at line 1486 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void Reserve (int new_size)
Reserves space to expand the field to at least the given size. This only
resizes the pointer array; it doesn't allocate any objects. If the
array is grown, it will always be at least doubled in size.
Defined at line 1582 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
int Capacity ()
Defined at line 1587 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
Element ** mutable_data ()
Gets the underlying array. This pointer is possibly invalidated by
any add or remove operation.
Defined at line 1510 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const Element *const * data ()
Defined at line 1516 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void Swap (RepeatedPtrField<Element> * other)
Swaps entire contents with "other". If they are on separate arenas, then
copies data.
Defined at line 1522 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void UnsafeArenaSwap (RepeatedPtrField<Element> * other)
Swaps entire contents with "other". Caller should guarantee that either
both fields are on the same arena or both are on the heap. Swapping between
different arenas with this function is disallowed and is caught via
ABSL_DCHECK.
Defined at line 1528 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void SwapElements (int index1, int index2)
Swaps two elements.
Defined at line 1536 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
iterator begin ()
Defined at line 1830 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_iterator begin ()
Defined at line 1835 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_iterator cbegin ()
Defined at line 1840 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
iterator end ()
Defined at line 1845 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_iterator end ()
Defined at line 1850 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_iterator cend ()
Defined at line 1855 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
pointer_iterator pointer_begin ()
Defined at line 1861 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_pointer_iterator pointer_begin ()
Defined at line 1866 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
pointer_iterator pointer_end ()
Defined at line 1871 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
const_pointer_iterator pointer_end ()
Defined at line 1876 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
size_t SpaceUsedExcludingSelfLong ()
Returns (an estimate of) the number of bytes used by the repeated field,
excluding sizeof(*this).
Defined at line 1546 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void AddAllocated (Element * value)
Adds an already-allocated object, passing ownership to the
RepeatedPtrField.
Note that some special behavior occurs with respect to arenas:
(i) if this field holds submessages, the new submessage will be copied if
the original is in an arena and this RepeatedPtrField is either in a
different arena, or on the heap.
(ii) if this field holds strings, the passed-in string *must* be
heap-allocated, not arena-allocated. There is no way to dynamically check
this at runtime, so User Beware.
Requires: value != nullptr
Defined at line 1557 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
Element * ReleaseLast ()
Removes and returns the last element, passing ownership to the caller.
Requires: size() > 0
If this RepeatedPtrField is on an arena, an object copy is required to pass
ownership back to the user (for compatible semantics). Use
UnsafeArenaReleaseLast() if this behavior is undesired.
Defined at line 1567 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void UnsafeArenaAddAllocated (Element * value)
Adds an already-allocated object, skipping arena-ownership checks. The user
must guarantee that the given object is in the same arena as this
RepeatedPtrField.
It is also useful in legacy code that uses temporary ownership to avoid
copies. Example:
RepeatedPtrField
<T
> temp_field;
temp_field.UnsafeArenaAddAllocated(new T);
... // Do something with temp_field
temp_field.UnsafeArenaExtractSubrange(0, temp_field.size(), nullptr);
If you put temp_field on the arena this fails, because the ownership
transfers to the arena at the "AddAllocated" call and is not released
anymore, causing a double delete. UnsafeArenaAddAllocated prevents this.
Requires: value != nullptr
Defined at line 1562 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
pointer UnsafeArenaReleaseLast ()
Removes and returns the last element. Unlike ReleaseLast, the returned
pointer is always to the original object. This may be in an arena, in
which case it would have the arena's lifetime.
Requires: current_size_ > 0
Defined at line 1572 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void ExtractSubrange (int start, int num, Element ** elements)
Extracts elements with indices in the range "[start .. start+num-1]".
The caller assumes ownership of the extracted elements and is responsible
for deleting them when they are no longer needed.
If "elements" is non-nullptr, then pointers to the extracted elements
are stored in "elements[0 .. num-1]" for the convenience of the caller.
If "elements" is nullptr, then the caller must use some other mechanism
to perform any further operations (like deletion) on these elements.
Caution: implementation also moves elements with indices [start+num ..].
Calling this routine inside a loop can cause quadratic behavior.
Memory copying behavior is identical to ReleaseLast(), described above: if
this RepeatedPtrField is on an arena, an object copy is performed for each
returned element, so that all returned element pointers are to
heap-allocated copies. If this copy is not desired, the user should call
UnsafeArenaExtractSubrange().
Defined at line 1413 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
void UnsafeArenaExtractSubrange (int start, int num, Element ** elements)
Identical to ExtractSubrange() described above, except that no object
copies are ever performed. Instead, the raw object pointers are returned.
Thus, if on an arena, the returned objects must not be freed, because they
will not be heap-allocated objects.
Defined at line 1453 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
int ClearedCount ()
Gets the number of cleared objects that are currently being kept
around for reuse.
Defined at line 1577 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
iterator erase (const_iterator position)
Removes the element referenced by position.
Returns an iterator to the element immediately following the removed
element.
Invalidates all iterators at or after the removed element, including end().
Defined at line 1493 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
iterator erase (const_iterator first, const_iterator last)
Removes the elements in the range [first, last).
Returns an iterator to the element immediately following the removed range.
Invalidates all iterators at or after the removed range, including end().
Defined at line 1500 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
Arena * GetArena ()
Gets the arena on which this RepeatedPtrField stores its elements.
Defined at line 1541 of file ../../third_party/protobuf/src/google/protobuf/repeated_ptr_field.h
Friends
template <typename T>
class WeakRepeatedPtrField
template <typename T>
class TcParser
template <typename T>
class Arena