Go to the documentation of this file.
37 #ifndef GOOGLE_PROTOBUF_MAP_H__
38 #define GOOGLE_PROTOBUF_MAP_H__
40 #include <initializer_list>
53 #error "You cannot SWIG proto headers"
56 #include <google/protobuf/port_def.inc>
61 template <
typename Key,
typename T>
66 template <
typename Enum>
70 template <
typename Derived,
typename Key,
typename T,
75 template <
typename Derived,
typename Key,
typename T,
80 template <
typename Key,
typename T>
85 class GeneratedMessageReflection;
91 template <
typename Key,
typename T>
97 MapPair(
const Key& other_first,
const T& other_second)
105 template <
typename T1,
typename T2>
106 operator std::pair<T1, T2>()
const {
128 template <
typename Key,
typename T>
160 if (
this != &other) {
161 if (
arena_ != other.arena_) {
170 template <
class InputIt>
193 template <
typename U>
206 template <
typename X>
216 return reinterpret_cast<pointer>(
223 #if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
227 ::operator
delete(
p);
232 #if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \
233 !defined(GOOGLE_PROTOBUF_OS_NACL) && \
234 !defined(GOOGLE_PROTOBUF_OS_EMSCRIPTEN)
235 template <
class NodeType,
class...
Args>
241 new (
const_cast<void*
>(
static_cast<const void*
>(
p)))
242 NodeType(std::forward<Args>(
args)...);
245 template <
class NodeType>
255 template <
typename X>
260 template <
typename X>
265 template <
typename X>
273 return (std::numeric_limits<size_type>::max)();
293 const Key&
key()
const {
return k_; }
368 return reinterpret_cast<Node*
>(k);
377 bool operator()(
const Key* n0,
const Key* n1)
const {
return *n0 < *n1; }
380 typedef std::set<Key*, KeyCompare, KeyPtrAllocator>
Tree;
384 template <
typename KeyValueType>
405 template <
typename U>
443 return a.node_ ==
b.node_;
446 return a.node_ !=
b.node_;
458 if (++tree_it ==
tree->end()) {
528 }
while (node !=
NULL);
533 typename Tree::iterator tree_it =
tree->begin();
536 typename Tree::iterator
next = tree_it;
538 tree->erase(tree_it);
541 }
while (tree_it !=
tree->end());
553 return static_cast<size_type>(1) << (
sizeof(
void**) >= 8 ? 60 : 28);
566 if (
p.first.node_ !=
NULL)
567 return std::make_pair(
iterator(
p.first),
false);
573 Node* node = Alloc<Node>(1);
577 return std::make_pair(result,
true);
582 std::pair<iterator, bool>
insert(
const Key& k) {
583 std::pair<const_iterator, size_type>
p =
FindHelper(k);
585 if (
p.first.node_ !=
NULL)
586 return std::make_pair(
iterator(
p.first),
false);
592 Node* node = Alloc<Node>(1);
593 typedef typename Allocator::template rebind<Key>::other KeyAllocator;
594 KeyAllocator(
alloc_).construct(&node->
kv.
key(), k);
597 return std::make_pair(result,
true);
602 return insert(kv).first->value();
607 typename Tree::iterator tree_it;
608 const bool is_list =
it.revalidate_if_necessary(&tree_it);
615 table_[
b] =
static_cast<void*
>(head);
619 tree->erase(*tree_it);
623 b &= ~static_cast<size_type>(1);
642 std::pair<const_iterator, size_type>
FindHelper(
const Key& k)
const {
645 std::pair<const_iterator, size_type>
FindHelper(
const Key& k,
656 }
while (node !=
NULL);
659 b &= ~static_cast<size_t>(1);
661 Key*
key =
const_cast<Key*
>(&k);
662 typename Tree::iterator tree_it =
tree->find(
key);
663 if (tree_it !=
tree->end()) {
668 return std::make_pair(
end(),
b);
711 table_[
b] =
static_cast<void*
>(node);
723 this,
b & ~
static_cast<size_t>(1));
737 const size_type lo_cutoff = hi_cutoff / 4;
741 if (PROTOBUF_PREDICT_FALSE(new_size >= hi_cutoff)) {
746 }
else if (PROTOBUF_PREDICT_FALSE(new_size <= lo_cutoff &&
748 size_type lg2_of_size_reduction_factor = 1;
752 const size_type hypothetical_size = new_size * 5 / 4 + 1;
753 while ((hypothetical_size << lg2_of_size_reduction_factor) <
755 ++lg2_of_size_reduction_factor;
757 size_type new_num_buckets = std::max<size_type>(
770 void**
const old_table =
table_;
783 Dealloc<void*>(old_table, old_table_size);
792 }
while (node !=
NULL);
797 typename Tree::iterator tree_it =
tree->begin();
801 }
while (++tree_it !=
tree->end());
842 typename Allocator::template rebind<Tree>::other tree_allocator(
alloc_);
843 Tree*
tree = tree_allocator.allocate(1);
848 tree_allocator.construct(
tree,
861 while (node !=
NULL) {
880 }
while (node !=
NULL);
883 return count >= kMaxLength;
893 return std::equal_to<Key>()(
k0,
k1);
905 template <
typename U>
907 typedef typename Allocator::template rebind<U>::other alloc_type;
908 return alloc_type(
alloc_).allocate(
n);
912 template <
typename U>
914 typedef typename Allocator::template rebind<U>::other alloc_type;
915 alloc_type(
alloc_).deallocate(t,
n);
920 Dealloc<Node>(node, 1);
924 typename Allocator::template rebind<Tree>::other tree_allocator(
alloc_);
925 tree_allocator.destroy(
tree);
926 tree_allocator.deallocate(
tree, 1);
932 void** result = Alloc<void*>(
n);
933 memset(result, 0,
n *
sizeof(result[0]));
940 #if defined(__x86_64__) && defined(__GNUC__) && \
941 !defined(GOOGLE_PROTOBUF_NO_RDTSC)
943 asm(
"rdtsc" :
"=a"(lo),
"=d"(hi));
944 s += ((
static_cast<uint64>(hi) << 32) | lo);
983 return a.it_ ==
b.it_;
1021 return a.it_ ==
b.it_;
1056 return (*value)->second;
1073 return it ==
end() ? 0 : 1;
1084 return std::pair<const_iterator, const_iterator>(
it,
it);
1087 return std::pair<const_iterator, const_iterator>(
begin,
it);
1093 return std::pair<iterator, iterator>(
it,
it);
1096 return std::pair<iterator, iterator>(
begin,
it);
1102 std::pair<typename InnerMap::iterator, bool>
p =
1107 return std::pair<iterator, bool>(iterator(
p.first),
p.second);
1109 template <
class InputIt>
1112 iterator exist_it =
find(
it->first);
1113 if (exist_it ==
end()) {
1139 while (
first != last) {
1147 if (
this != &other) {
1184 Arena::CreateInArenaStorage(
const_cast<Key*
>(&
value->first),
arena_);
1185 Arena::CreateInArenaStorage(&
value->second,
arena_);
1186 const_cast<Key&
>(
value->first) =
key;
1197 Arena::CreateInArenaStorage(
const_cast<Key*
>(&
p->first),
arena_);
1198 Arena::CreateInArenaStorage(&
p->second,
arena_);
1199 const_cast<Key&
>(
p->first) =
value.first;
1200 p->second =
value.second;
1212 template <
typename Derived,
typename K,
typename V,
1215 int default_enum_value>
1222 #include <google/protobuf/port_undef.inc>
1224 #endif // GOOGLE_PROTOBUF_MAP_H__
void ** CreateEmptyTable(size_type n)
iterator erase(iterator pos)
iterator find(const Key &k)
ptrdiff_t difference_type
size_type index_of_first_non_null_
std::forward_iterator_tag iterator_category
const Descriptor::ReservedRange value
const typedef value_type & const_reference
const T & at(const key_type &key) const
MapAllocator< KeyValuePair > Allocator
iterator_base(TreeIterator tree_it, const InnerMap *m, size_type index)
friend bool operator==(const const_iterator &a, const const_iterator &b)
Map & operator=(const Map &other)
ptrdiff_t difference_type
bool contains(const Key &k) const
const_iterator find(const key_type &key) const
static bool TableEntryIsList(void *const *table, size_type b)
const_iterator begin() const
bool operator==(const MapAllocator< X > &other) const
MapAllocator(Arena *arena)
bool TableEntryIsTooLong(size_type b)
void DestroyTree(Tree *tree)
void deallocate(pointer p, size_type n)
iterator(const InnerIt &it)
std::pair< iterator, bool > insert(const value_type &value)
void TreeConvert(size_type b)
void construct(pointer p, const_reference t)
std::pair< iterator, bool > insert(const KeyValuePair &kv)
std::forward_iterator_tag iterator_category
void DestroyNode(Node *node)
Tree::iterator TreeIterator
const_reference operator*() const
void Resize(size_t new_num_buckets)
InnerMap::const_iterator InnerIt
#define T(upbtypeconst, upbtype, ctype, default_value)
bool revalidate_if_necessary(TreeIterator *it)
std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const
KeyValuePair(const Key &k, value_type *v)
pointer allocate(size_type n, const void *=0)
bool TableEntryIsNonEmptyList(size_type b) const
reference operator*() const
size_type count(const key_type &key) const
GLboolean GLboolean GLboolean b
bool ResizeIfLoadIsOutOfRange(size_type new_size)
iterator_base(Node *n, const InnerMap *m, size_type index)
GLenum GLsizei GLsizei GLint * values
bool TableEntryIsList(size_type b) const
reference operator*() const
size_type BucketNumber(const Key &k) const
InnerMap(size_type n, hasher h, Allocator alloc)
const_iterator end() const
MapPair(const Key &other_first)
const hasher & hash_function() const
T & at(const key_type &key)
hasher hash_function() const
Map & operator=(Map &&other) noexcept
std::pair< iterator, iterator > equal_range(const key_type &key)
static bool TableEntryIsTree(void *const *table, size_type b)
bool contains(const Key &key) const
value_type * CreateValueTypeInternal(const Key &key)
bool TableEntryIsTree(size_type b) const
const typedef value_type & reference
const typedef value_type & const_reference
friend bool operator!=(const iterator_base &a, const iterator_base &b)
Map(const InputIt &first, const InputIt &last)
const_iterator begin() const
pointer operator->() const
std::set< Key *, KeyCompare, KeyPtrAllocator > Tree
std::pair< const_iterator, size_type > FindHelper(const Key &k) const
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
const typedef Key first_type
std::pair< const_iterator, size_type > FindHelper(const Key &k, TreeIterator *it) const
void DestructorSkippable_
iterator_base(const InnerMap *m)
size_type TableSize(size_type n)
const_iterator(const InnerIt &it)
static Key * KeyPtrFromNodePtr(Node *node)
void TransferTree(void *const *table, size_type index)
Map::value_type value_type
InnerMap::iterator InnerIt
Map(Map &&other) noexcept
const_iterator operator++(int)
const SETUP_TEARDOWN_TESTCONTEXT char * key
iterator InsertUniqueInTree(size_type b, Node *node)
iterator find(const key_type &key)
size_type CopyListToTree(size_type b, Tree *tree)
iterator_base & operator++()
MapPair(const MapPair &other)
#define GOOGLE_CHECK(EXPRESSION)
Node * EraseFromLinkedList(Node *item, Node *head)
bool TableEntryIsEmpty(size_type b) const
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
value_type * value() const
static bool TableEntryIsNonEmptyList(void *const *table, size_type b)
const_iterator cbegin() const
std::pair< iterator, bool > insert(const Key &k)
iterator_base operator++(int)
MapPair< Key, T > value_type
iterator InsertUnique(size_type b, Node *node)
bool operator()(const Key *n0, const Key *n1) const
friend bool operator!=(const const_iterator &a, const const_iterator &b)
const_iterator find(const Key &k, TreeIterator *it) const
const_iterator end() const
const typedef value_type * const_pointer
friend bool operator!=(const iterator &a, const iterator &b)
void InternalArenaConstructable_
void Dealloc(U *t, size_type n)
const typedef value_type * pointer
MapPair(const Key &other_first, const T &other_second)
static bool TableEntryIsEmpty(void *const *table, size_type b)
Map::value_type value_type
const upb_json_parsermethod * m
iterator InsertUniqueInList(size_type b, Node *node)
IMGUI_API void Initialize(ImGuiContext *context)
MapAllocator(const MapAllocator< X > &allocator)
Value & operator[](const Key &k)
iterator_base< KeyValuePair > iterator
iterator_base(const iterator_base< U > &it)
void SearchFrom(size_type start_bucket)
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(InnerMap)
size_type max_size() const
bool IsMatch(const Key &k0, const Key &k1) const
void TransferList(void *const *table, size_type index)
const_iterator & operator++()
size_type erase(const key_type &key)
friend bool operator==(const iterator &a, const iterator &b)
Allocator::template rebind< Key * >::other KeyPtrAllocator
void DestructorSkippable_
ptrdiff_t difference_type
static size_t next(const upb_table *t, size_t i)
bool operator!=(const MapAllocator< X > &other) const
pointer operator->() const
GLsizei const GLfloat * value
void insert(InputIt first, InputIt last)
void erase(iterator first, iterator last)
friend bool operator==(const iterator_base &a, const iterator_base &b)
const_iterator find(const Key &k) const
static Node * NodePtrFromKeyPtr(Key *k)
static size_type max_size()
iterator_base< const KeyValuePair > const_iterator
const typedef value_type * const_pointer
const_pointer operator->() const
GLboolean GLboolean GLboolean GLboolean a
const_iterator cend() const
T & operator[](const key_type &key)
void SetDefaultEnumValue(int default_enum_value)
GLfloat GLfloat GLfloat GLfloat h
void insert(std::initializer_list< value_type > values)
value_type * CreateValueTypeInternal(const value_type &value)
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:56