Mercurial > hg > CbC > CbC_gcc
comparison gcc/hash-map.h @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* A type-safe hash map. | 1 /* A type-safe hash map. |
2 Copyright (C) 2014-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2014-2018 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GCC. | 4 This file is part of GCC. |
5 | 5 |
6 GCC is free software; you can redistribute it and/or modify it under | 6 GCC is free software; you can redistribute it and/or modify it under |
7 the terms of the GNU General Public License as published by the Free | 7 the terms of the GNU General Public License as published by the Free |
60 { | 60 { |
61 gt_ggc_mx (e.m_key); | 61 gt_ggc_mx (e.m_key); |
62 gt_ggc_mx (e.m_value); | 62 gt_ggc_mx (e.m_value); |
63 } | 63 } |
64 | 64 |
65 static void ggc_maybe_mx (hash_entry &e) | |
66 { | |
67 if (Traits::maybe_mx) | |
68 ggc_mx (e); | |
69 } | |
70 | |
65 static void pch_nx (hash_entry &e) | 71 static void pch_nx (hash_entry &e) |
66 { | 72 { |
67 gt_pch_nx (e.m_key); | 73 gt_pch_nx (e.m_key); |
68 gt_pch_nx (e.m_value); | 74 gt_pch_nx (e.m_value); |
69 } | 75 } |
70 | 76 |
71 static void pch_nx (hash_entry &e, gt_pointer_operator op, void *c) | 77 static void pch_nx (hash_entry &e, gt_pointer_operator op, void *c) |
72 { | 78 { |
73 pch_nx_helper (e.m_key, op, c); | 79 pch_nx_helper (e.m_key, op, c); |
74 pch_nx_helper (e.m_value, op, c); | 80 pch_nx_helper (e.m_value, op, c); |
81 } | |
82 | |
83 static int keep_cache_entry (hash_entry &e) | |
84 { | |
85 return ggc_marked_p (e.m_key); | |
75 } | 86 } |
76 | 87 |
77 private: | 88 private: |
78 template<typename T> | 89 template<typename T> |
79 static void | 90 static void |
210 { | 221 { |
211 ++m_iter; | 222 ++m_iter; |
212 return *this; | 223 return *this; |
213 } | 224 } |
214 | 225 |
215 std::pair<Key, Value> operator* () | 226 std::pair<const Key&, Value&> operator* () |
216 { | 227 { |
217 hash_entry &e = *m_iter; | 228 hash_entry &e = *m_iter; |
218 return std::pair<Key, Value> (e.m_key, e.m_value); | 229 return std::pair<const Key&, Value&> (e.m_key, e.m_value); |
219 } | 230 } |
220 | 231 |
221 bool | 232 bool |
222 operator != (const iterator &other) const | 233 operator != (const iterator &other) const |
223 { | 234 { |
235 | 246 |
236 private: | 247 private: |
237 | 248 |
238 template<typename T, typename U, typename V> friend void gt_ggc_mx (hash_map<T, U, V> *); | 249 template<typename T, typename U, typename V> friend void gt_ggc_mx (hash_map<T, U, V> *); |
239 template<typename T, typename U, typename V> friend void gt_pch_nx (hash_map<T, U, V> *); | 250 template<typename T, typename U, typename V> friend void gt_pch_nx (hash_map<T, U, V> *); |
240 template<typename T, typename U, typename V> friend void gt_pch_nx (hash_map<T, U, V> *, gt_pointer_operator, void *); | 251 template<typename T, typename U, typename V> friend void gt_pch_nx (hash_map<T, U, V> *, gt_pointer_operator, void *); |
252 template<typename T, typename U, typename V> friend void gt_cleare_cache (hash_map<T, U, V> *); | |
241 | 253 |
242 hash_table<hash_entry> m_table; | 254 hash_table<hash_entry> m_table; |
243 }; | 255 }; |
244 | 256 |
245 /* ggc marking routines. */ | 257 /* ggc marking routines. */ |
258 gt_pch_nx (&h->m_table); | 270 gt_pch_nx (&h->m_table); |
259 } | 271 } |
260 | 272 |
261 template<typename K, typename V, typename H> | 273 template<typename K, typename V, typename H> |
262 static inline void | 274 static inline void |
275 gt_cleare_cache (hash_map<K, V, H> *h) | |
276 { | |
277 if (h) | |
278 gt_cleare_cache (&h->m_table); | |
279 } | |
280 | |
281 template<typename K, typename V, typename H> | |
282 static inline void | |
263 gt_pch_nx (hash_map<K, V, H> *h, gt_pointer_operator op, void *cookie) | 283 gt_pch_nx (hash_map<K, V, H> *h, gt_pointer_operator op, void *cookie) |
264 { | 284 { |
265 op (&h->m_table.m_entries, cookie); | 285 op (&h->m_table.m_entries, cookie); |
266 } | 286 } |
267 | 287 |