Go to the documentation of this file.
5 #ifndef UTIL_SPARSE_ARRAY_H_
6 #define UTIL_SPARSE_ARRAY_H_
93 #define __has_feature(x) 0
98 #if __has_feature(memory_sanitizer)
99 #include <sanitizer/msan_interface.h>
109 template<
typename Value>
155 void resize(
int new_max_size);
160 if (
dense_.data() != NULL)
178 static bool less(
const IndexValue&
a,
const IndexValue&
b);
213 assert(
false &&
"illegal index");
219 if (!allow_existing) {
251 #if __has_feature(memory_sanitizer)
253 #elif defined(RE2_ON_VALGRIND)
265 template<
typename Value>
268 template<
typename Value>
271 sparse_(src.max_size()),
272 dense_(src.max_size()) {
277 template<
typename Value>
280 sparse_(
std::
move(src.sparse_)),
281 dense_(
std::
move(src.dense_)) {
285 template<
typename Value>
299 template<
typename Value>
309 template<
typename Value>
324 template<
typename Value>
326 DebugCheckInvariants();
327 if (new_max_size > max_size()) {
328 const int old_max_size = max_size();
334 std::copy_n(sparse_.data(), old_max_size,
a.data());
335 std::copy_n(dense_.data(), old_max_size,
b.data());
340 MaybeInitializeMemory(old_max_size, new_max_size);
342 if (
size_ > new_max_size)
343 size_ = new_max_size;
344 DebugCheckInvariants();
348 template<
typename Value>
351 assert(
i < max_size());
360 template<
typename Value>
362 assert(!has_index(
i));
363 assert(
size_ < max_size());
370 sparse_(max_size), dense_(max_size) {
371 MaybeInitializeMemory(
size_, max_size);
372 DebugCheckInvariants();
376 DebugCheckInvariants();
381 assert(
size_ <= max_size());
386 const IndexValue&
b) {
387 return a.index_ <
b.index_;
392 #endif // UTIL_SPARSE_ARRAY_H_
iterator set(int i, const Value &v)
PODArray< IndexValue > dense_
const typedef IndexValue * const_iterator
const_iterator end() const
void MaybeInitializeMemory(int min, int max)
const Value & value() const
void resize(int new_max_size)
iterator SetExistingInternal(int i, const Value &v)
iterator SetInternal(bool allow_existing, int i, const Value &v)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
SparseArray & operator=(const SparseArray &src)
Value & get_existing(int i)
iterator set_new(int i, const Value &v)
static bool less(const IndexValue &a, const IndexValue &b)
iterator set_existing(int i, const Value &v)
bool has_index(int i) const
const Value & get_existing(int i) const
void DebugCheckInvariants() const
const_iterator begin() const
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:15