GCC Middle and Back End API Reference
typed_splay_tree< KEY_TYPE, VALUE_TYPE > Class Template Reference

#include <typed-splay-tree.h>

Inheritance diagram for typed_splay_tree< KEY_TYPE, VALUE_TYPE >:
Collaboration diagram for typed_splay_tree< KEY_TYPE, VALUE_TYPE >:

Data Structures

struct  splay_tree_node_s
 

Public Types

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)
 
typedef int(* foreach_fn) (key_type, value_type, void *)
 

Public Member Functions

 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)
 
void remove (key_type k)
 
value_type max ()
 
value_type min ()
 
int foreach (foreach_fn, void *)
 

Private Types

typedef key_type splay_tree_key
 
typedef value_type splay_tree_value
 
typedef splay_tree_node_ssplay_tree_node
 

Private Member Functions

 typed_splay_tree (const typed_splay_tree &)
 
typed_splay_treeoperator= (const typed_splay_tree &)
 
void KDEL (splay_tree_key)
 
void VDEL (splay_tree_value)
 
void splay_tree_delete_helper (splay_tree_node)
 
void splay_tree_splay (splay_tree_key)
 
splay_tree_node splay_tree_insert (splay_tree_key, splay_tree_value)
 
void splay_tree_remove (splay_tree_key key)
 
splay_tree_node splay_tree_lookup (splay_tree_key key)
 
splay_tree_node splay_tree_predecessor (splay_tree_key)
 
splay_tree_node splay_tree_successor (splay_tree_key)
 
splay_tree_node splay_tree_max ()
 
splay_tree_node splay_tree_min ()
 

Static Private Member Functions

static void rotate_left (splay_tree_node *, splay_tree_node, splay_tree_node)
 
static void rotate_right (splay_tree_node *, splay_tree_node, splay_tree_node)
 
static int splay_tree_foreach_helper (splay_tree_node, foreach_fn, void *)
 
static value_type node_to_value (splay_tree_node node)
 

Private Attributes

splay_tree_node root
 
compare_fn comp
 
delete_key_fn delete_key
 
delete_value_fn delete_value
 

Detailed Description

template<typename KEY_TYPE, typename VALUE_TYPE>
class typed_splay_tree< KEY_TYPE, VALUE_TYPE >
A typesafe wrapper around libiberty's splay-tree.h.
   Copyright (C) 2015-2024 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/>.   
Typesafe wrapper around libiberty's splay-tree.h.   

Member Typedef Documentation

◆ compare_fn

◆ delete_key_fn

◆ delete_value_fn

◆ foreach_fn

◆ key_type

◆ splay_tree_key

◆ splay_tree_node

◆ splay_tree_value

◆ value_type

Constructor & Destructor Documentation

◆ typed_splay_tree() [1/2]

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 )
inline
Constructor for typed_splay_tree <K, V>.   

References comp, and NULL.

◆ ~typed_splay_tree()

Destructor for typed_splay_tree <K, V>.   

◆ typed_splay_tree() [2/2]

Member Function Documentation

◆ foreach()

int typed_splay_tree< KEY_TYPE, VALUE_TYPE >::foreach ( foreach_fn foreach_fn,
void * user_data )
inline
Call OUTER_CB, passing it the OUTER_USER_DATA, for every node,
following an in-order traversal.  If OUTER_CB ever returns a non-zero
value, the iteration ceases immediately, and the value is returned.
Otherwise, this function returns 0.   

Referenced by edit_context::print_diff().

◆ insert()

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.   

Referenced by edit_context::get_or_insert_file(), and edited_file::get_or_insert_line().

◆ KDEL()

◆ lookup()

Lookup KEY, returning a value if present, and NULL
otherwise.   

Referenced by edit_context::get_file(), and edited_file::get_line().

◆ max()

Get the value with maximal key.   

◆ min()

Get the value with minimal key.   

Referenced by edited_file::print_diff().

◆ node_to_value()

VALUE_TYPE typed_splay_tree< KEY_TYPE, VALUE_TYPE >::node_to_value ( splay_tree_node node)
inlinestaticprivate
Internal function for converting from splay_tree_node to
VALUE_TYPE.   

References typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::value.

◆ operator=()

◆ predecessor()

Return the immediate predecessor of KEY, or NULL if there is no
predecessor.  KEY need not be present in the tree.   

◆ remove()

Remove a node (associating KEY with VALUE).   

◆ rotate_left()

void typed_splay_tree< KEY_TYPE, VALUE_TYPE >::rotate_left ( splay_tree_node * pp,
splay_tree_node p,
splay_tree_node n )
inlinestaticprivate
Rotate the edge joining the left child N with its parent P.  PP is the
grandparents' pointer to P.   

References ggc_alloc(), typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::left, and typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::right.

◆ rotate_right()

void typed_splay_tree< KEY_TYPE, VALUE_TYPE >::rotate_right ( splay_tree_node * pp,
splay_tree_node p,
splay_tree_node n )
inlinestaticprivate
Rotate the edge joining the right child N with its parent P.  PP is the
grandparents' pointer to P.   

References ggc_alloc(), typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::left, and typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::right.

◆ splay_tree_delete_helper()

◆ splay_tree_foreach_helper()

int typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_foreach_helper ( splay_tree_node node,
foreach_fn fn,
void * data )
staticprivate
Call FN, passing it the DATA, for every node below NODE, all of
which are from SP, following an in-order traversal.  If FN every
returns a non-zero value, the iteration ceases immediately, and the
value is returned.  Otherwise, this function returns 0.   

References typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::back, typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::key, typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::left, NULL, typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::right, and typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::value.

◆ splay_tree_insert()

◆ splay_tree_lookup()

Lookup KEY in SP, returning VALUE if present, and NULL
otherwise.   

References comp.

◆ splay_tree_max()

◆ splay_tree_min()

◆ splay_tree_predecessor()

Return the immediate predecessor KEY, or NULL if there is no
predecessor.  KEY need not be present in the tree.   

References typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::left, NULL, and typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::right.

◆ splay_tree_remove()

◆ splay_tree_splay()

◆ splay_tree_successor()

Return the immediate successor KEY, or NULL if there is no
successor.  KEY need not be present in the tree.   

References typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::left, NULL, and typed_splay_tree< KEY_TYPE, VALUE_TYPE >::splay_tree_node_s::right.

◆ successor()

Return the immediate successor of KEY, or NULL if there is no
successor.  KEY need not be present in the tree.   

Referenced by edited_file::print_diff().

◆ VDEL()

Field Documentation

◆ comp

◆ delete_key

◆ delete_value

◆ root


The documentation for this class was generated from the following file: