/usr/lib/gcc/x86_64-linux-gnu/5/plugin/include/typed-splay-tree.h is in gcc-5-plugin-dev 5.5.0-12ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | /* A typesafe wrapper around libiberty's splay-tree.h.
Copyright (C) 2015 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_TYPED_SPLAY_TREE_H
#define GCC_TYPED_SPLAY_TREE_H
#include "splay-tree.h"
/* Typesafe wrapper around libiberty's splay-tree.h. */
template <typename KEY_TYPE, typename VALUE_TYPE>
class typed_splay_tree
{
public:
typedef KEY_TYPE key_type;
typedef VALUE_TYPE value_type;
typedef int (*compare_fn) (key_type, key_type);
typedef void (*delete_key_fn) (key_type);
typedef void (*delete_value_fn) (value_type);
typed_splay_tree (compare_fn,
delete_key_fn,
delete_value_fn);
~typed_splay_tree ();
value_type lookup (key_type k);
value_type predecessor (key_type k);
value_type successor (key_type k);
void insert (key_type k, value_type v);
private:
static value_type node_to_value (splay_tree_node node);
private:
::splay_tree m_inner;
};
/* Constructor for typed_splay_tree <K, V>. */
template <typename KEY_TYPE, typename VALUE_TYPE>
inline typed_splay_tree<KEY_TYPE, VALUE_TYPE>::
typed_splay_tree (compare_fn compare_fn,
delete_key_fn delete_key_fn,
delete_value_fn delete_value_fn)
{
m_inner = splay_tree_new ((splay_tree_compare_fn)compare_fn,
(splay_tree_delete_key_fn)delete_key_fn,
(splay_tree_delete_value_fn)delete_value_fn);
}
/* Destructor for typed_splay_tree <K, V>. */
template <typename KEY_TYPE, typename VALUE_TYPE>
inline typed_splay_tree<KEY_TYPE, VALUE_TYPE>::
~typed_splay_tree ()
{
splay_tree_delete (m_inner);
}
/* Lookup KEY, returning a value if present, and NULL
otherwise. */
template <typename KEY_TYPE, typename VALUE_TYPE>
inline VALUE_TYPE
typed_splay_tree<KEY_TYPE, VALUE_TYPE>::lookup (key_type key)
{
splay_tree_node node = splay_tree_lookup (m_inner, (splay_tree_key)key);
return node_to_value (node);
}
/* Return the immediate predecessor of KEY, or NULL if there is no
predecessor. KEY need not be present in the tree. */
template <typename KEY_TYPE, typename VALUE_TYPE>
inline VALUE_TYPE
typed_splay_tree<KEY_TYPE, VALUE_TYPE>::predecessor (key_type key)
{
splay_tree_node node = splay_tree_predecessor (m_inner, (splay_tree_key)key);
return node_to_value (node);
}
/* Return the immediate successor of KEY, or NULL if there is no
successor. KEY need not be present in the tree. */
template <typename KEY_TYPE, typename VALUE_TYPE>
inline VALUE_TYPE
typed_splay_tree<KEY_TYPE, VALUE_TYPE>::successor (key_type k)
{
splay_tree_node node = splay_tree_successor (m_inner, (splay_tree_key)k);
return node_to_value (node);
}
/* Insert a new node (associating KEY with VALUE). If a
previous node with the indicated KEY exists, its data is replaced
with the new value. */
template <typename KEY_TYPE, typename VALUE_TYPE>
inline void
typed_splay_tree<KEY_TYPE, VALUE_TYPE>::insert (key_type key,
value_type value)
{
splay_tree_insert (m_inner,
(splay_tree_key)key,
(splay_tree_value)value);
}
/* Internal function for converting from splay_tree_node to
VALUE_TYPE. */
template <typename KEY_TYPE, typename VALUE_TYPE>
inline VALUE_TYPE
typed_splay_tree<KEY_TYPE, VALUE_TYPE>::node_to_value (splay_tree_node node)
{
if (node)
return (value_type)node->value;
else
return 0;
}
#endif /* GCC_TYPED_SPLAY_TREE_H */
|