Mercurial > hg > CbC > CbC_gcc
comparison gcc/hash-set.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 set. | 1 /* A type-safe hash set. |
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 |
78 | 78 |
79 /* Return the number of elements in the set. */ | 79 /* Return the number of elements in the set. */ |
80 | 80 |
81 size_t elements () const { return m_table.elements (); } | 81 size_t elements () const { return m_table.elements (); } |
82 | 82 |
83 /* Clear the hash table. */ | |
84 | |
85 void empty () { m_table.empty (); } | |
86 | |
83 class iterator | 87 class iterator |
84 { | 88 { |
85 public: | 89 public: |
86 explicit iterator (const typename hash_table<Traits>::iterator &iter) : | 90 explicit iterator (const typename hash_table<Traits>::iterator &iter) : |
87 m_iter (iter) {} | 91 m_iter (iter) {} |
121 template<typename T, typename U> friend void gt_pch_nx (hash_set<T, U> *, gt_pointer_operator, void *); | 125 template<typename T, typename U> friend void gt_pch_nx (hash_set<T, U> *, gt_pointer_operator, void *); |
122 | 126 |
123 hash_table<Traits> m_table; | 127 hash_table<Traits> m_table; |
124 }; | 128 }; |
125 | 129 |
130 /* Generic hash_set<TYPE> debug helper. | |
131 | |
132 This needs to be instantiated for each hash_set<TYPE> used throughout | |
133 the compiler like this: | |
134 | |
135 DEFINE_DEBUG_HASH_SET (TYPE) | |
136 | |
137 The reason we have a debug_helper() is because GDB can't | |
138 disambiguate a plain call to debug(some_hash), and it must be called | |
139 like debug<TYPE>(some_hash). */ | |
140 template<typename T> | |
141 void | |
142 debug_helper (hash_set<T> &ref) | |
143 { | |
144 for (typename hash_set<T>::iterator it = ref.begin (); | |
145 it != ref.end (); ++it) | |
146 { | |
147 debug_slim (*it); | |
148 fputc ('\n', stderr); | |
149 } | |
150 } | |
151 | |
152 #define DEFINE_DEBUG_HASH_SET(T) \ | |
153 template void debug_helper (hash_set<T> &); \ | |
154 DEBUG_FUNCTION void \ | |
155 debug (hash_set<T> &ref) \ | |
156 { \ | |
157 debug_helper <T> (ref); \ | |
158 } \ | |
159 DEBUG_FUNCTION void \ | |
160 debug (hash_set<T> *ptr) \ | |
161 { \ | |
162 if (ptr) \ | |
163 debug (*ptr); \ | |
164 else \ | |
165 fprintf (stderr, "<nil>\n"); \ | |
166 } | |
167 | |
126 /* ggc marking routines. */ | 168 /* ggc marking routines. */ |
127 | 169 |
128 template<typename K, typename H> | 170 template<typename K, typename H> |
129 static inline void | 171 static inline void |
130 gt_ggc_mx (hash_set<K, H> *h) | 172 gt_ggc_mx (hash_set<K, H> *h) |