summaryrefslogtreecommitdiff
path: root/gcc/pointer-set.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/pointer-set.h')
-rw-r--r--gcc/pointer-set.h111
1 files changed, 0 insertions, 111 deletions
diff --git a/gcc/pointer-set.h b/gcc/pointer-set.h
index a426534ac44..fc592121872 100644
--- a/gcc/pointer-set.h
+++ b/gcc/pointer-set.h
@@ -45,117 +45,6 @@ void pointer_set_traverse (const struct pointer_set_t *,
void *);
bool pointer_set_lookup (const pointer_set_t *, const void *, size_t *);
-/* A pointer map is represented the same way as a pointer_set, so
- the hash code is based on the address of the key, rather than
- its contents. Null keys are a reserved value. Deletion is not
- supported (yet). There is no mechanism for user control of hash
- function, equality comparison, initial size, or resizing policy. */
-
-template <typename T>
-class pointer_map : protected pointer_set_t
-{
- T *values;
-
-public:
- pointer_map ();
- ~pointer_map ();
- T *contains (const void *p);
- T *insert (const void *p, bool *existed_p = NULL);
- void traverse (bool (*fn) (const void *, T *, void *), void *data);
-};
-
-/* Allocate an empty pointer map. */
-template <typename T>
-pointer_map<T>::pointer_map (void)
-{
- n_elements = 0;
- log_slots = 8;
- n_slots = (size_t) 1 << log_slots;
-
- slots = XCNEWVEC (const void *, n_slots);
- values = XNEWVEC (T, n_slots);
-}
-
-/* Reclaims all memory associated with PMAP. */
-template <typename T>
-pointer_map<T>::~pointer_map (void)
-{
- XDELETEVEC (slots);
- XDELETEVEC (values);
-}
-
-/* Returns a pointer to the value to which P maps, if PMAP contains P. P
- must be nonnull. Return NULL if PMAP does not contain P.
-
- Collisions are resolved by linear probing. */
-template <typename T>
-T *
-pointer_map<T>::contains (const void *p)
-{
- size_t n;
- if (!pointer_set_lookup (this, p, &n))
- return NULL;
- return &values[n];
-}
-
-/* Inserts P into PMAP if it wasn't already there. Returns a pointer
- to the value. P must be nonnull. */
-template <typename T>
-T *
-pointer_map<T>::insert (const void *p, bool *existed_p)
-{
- size_t n;
-
- /* For simplicity, expand the map even if P is already there. This can be
- superfluous but can happen at most once. */
- /* ??? Fugly that we have to inline that here. */
- if (n_elements > n_slots / 4)
- {
- size_t old_n_slots = n_slots;
- const void **old_keys = slots;
- T *old_values = values;
- log_slots = log_slots + 1;
- n_slots = n_slots * 2;
- slots = XCNEWVEC (const void *, n_slots);
- values = XNEWVEC (T, n_slots);
- for (size_t i = 0; i < old_n_slots; ++i)
- if (old_keys[i])
- {
- const void *key = old_keys[i];
- pointer_set_lookup (this, key, &n);
- slots[n] = key;
- values[n] = old_values[i];
- }
- XDELETEVEC (old_keys);
- XDELETEVEC (old_values);
- }
-
- if (!pointer_set_lookup (this, p, &n))
- {
- ++n_elements;
- slots[n] = p;
- if (existed_p)
- *existed_p = false;
- }
- else if (existed_p)
- *existed_p = true;
-
- return &values[n];
-}
-
-/* Pass each pointer in PMAP to the function in FN, together with the pointer
- to the value and the fixed parameter DATA. If FN returns false, the
- iteration stops. */
-
-template <class T>
-void
-pointer_map<T>::traverse (bool (*fn) (const void *, T *, void *), void *data)
-{
- for (size_t i = 0; i < n_slots; ++i)
- if (slots[i] && !fn (slots[i], &values[i], data))
- break;
-}
-
struct pointer_map_t;
pointer_map_t *pointer_map_create (void);