feisty meow concerns codebase 2.140
symbol_tree.h
Go to the documentation of this file.
1#ifndef SYMBOL_TREE_CLASS
2#define SYMBOL_TREE_CLASS
3
4/*****************************************************************************\
5* *
6* Name : symbol_tree *
7* Author : Chris Koeritz *
8* *
9*******************************************************************************
10* Copyright (c) 1992-$now By Author. This program is free software; you can *
11* redistribute it and/or modify it under the terms of the GNU General Public *
12* License as published by the Free Software Foundation; either version 2 of *
13* the License or (at your option) any later version. This is online at: *
14* http://www.fsf.org/copyleft/gpl.html *
15* Please send any updates to: fred@gruntose.com *
16\*****************************************************************************/
17
18#include "tree.h"
19
20#include <basis/astring.h>
21#include <basis/definitions.h>
22
23namespace nodes {
24
25// forward.
26class symbol_tree_associations;
27
29
36class symbol_tree : public tree
37{
38public:
39 symbol_tree(const basis::astring &node_name, int estimated_elements = 100);
41
44 virtual ~symbol_tree();
46
50 DEFINE_CLASS_NAME("symbol_tree");
51
52 int children() const;
53
54 const basis::astring &name() const;
55
56 int estimated_elements() const;
57
58 symbol_tree *branch(int index) const;
59
60 void rehash(int estimated_elements);
62
65
70 bool add(symbol_tree *to_add);
72
73 virtual basis::outcome prune(tree *to_zap);
75
80
81 symbol_tree *find(const basis::astring &to_find,
82 find_methods how,
86
95 void sort();
97
100
101private:
102 symbol_tree_associations *_associations;
103 basis::astring *_name;
104};
105
106} // namespace.
107
108#endif
109
Provides a dynamically resizable ASCII character string.
Definition astring.h:35
Outcomes describe the state of completion for an operation.
Definition outcome.h:31
A symbol table that supports scope nesting and/or trees of symbol tables.
Definition symbol_tree.h:37
DEFINE_CLASS_NAME("symbol_tree")
void sort()
sorts the sub-nodes of this symbol_tree.
basis::astring text_form() const
traverses the tree to build a textual list of the nodes.
virtual basis::outcome prune(tree *to_zap)
removes a sub-tree "to_zap".
void hash_appropriately(int estimated_elements)
resizes the hashing parameter to limit bucket sizes.
bool add(symbol_tree *to_add)
adds a child to this symbol_tree.
symbol_tree * find(const basis::astring &to_find, find_methods how, basis::string_comparator_function *comp=NULL_POINTER)
returns the node specified by "to_find" or NULL_POINTER.
const basis::astring & name() const
returns the name of this node.
virtual ~symbol_tree()
all child nodes will be deleted too.
symbol_tree * branch(int index) const
returns the "index"th branch.
void rehash(int estimated_elements)
resizes the underlying symbol_table for this node.
int estimated_elements() const
returns the number of bits in this node's table.
int children() const
returns the number of children of this node.
A dynamically linked tree with an arbitrary number of branches.
Definition tree.h:40
Constants and objects used throughout HOOPLE.
#define NULL_POINTER
The value representing a pointer to nothing.
Definition definitions.h:32
bool string_comparator_function(const astring &a, const astring &b)
returns true if the strings "a" and "b" are considered equal.
Definition astring.h:449