Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
SortedBinTree.h
1 /*
2  * $Id$
3  * Copyright (c) 2004, Alfheim Corporation.
4  *
5  * elm/inhstruct/SortedBinTree.h -- abstract binary tree.
6  */
7 #ifndef ELM_INHSTRUCT_SORTEDBINTREE_H
8 #define ELM_INHSTRUCT_SORTEDBINTREE_H
9 
10 #include <elm/inhstruct/BinTree.h>
11 
12 namespace elm { namespace inhstruct {
13 
14 // SortedBinTree class
15 class SortedBinTree: protected BinTree {
16 private:
17  void insert(Node *node, Node *new_node);
18  Node *relink(Node *left, Node *right);
19  Node *remove(Node *node, Node *rem_node);
20 
21 protected:
22  virtual int compare(Node *node1, Node *node2) = 0;
23 
24 public:
25  virtual ~SortedBinTree(void) { }
26 
27  // Accessors
28  inline bool isEmpty(void);
29  inline int count(void);
30  Node *get(Node *node);
31  inline bool contains(Node *node);
32  inline void visit(Visitor *visitor);
33  inline void search(Visitor *visitor);
34 
35  // Modifiers
36  void insert(Node *node);
37  void remove(Node *node);
38  inline void clear(void);
39 };
40 
41 
42 // SortedBinTree inlines
43 inline bool SortedBinTree::isEmpty(void) {
44  return BinTree::isEmpty();
45 }
46 
47 inline int SortedBinTree::count(void) {
48  return BinTree::count();
49 }
50 
51 inline bool SortedBinTree::contains(Node *node) {
52  return get(node) != 0;
53 }
54 
55 inline void SortedBinTree::visit(Visitor *visitor) {
56  return BinTree::visit(visitor);
57 }
58 
59 inline void SortedBinTree::search(Visitor *visitor) {
60  BinTree::search(visitor);
61 }
62 
63 inline void SortedBinTree::clear(void) {
65 }
66 
67 } } // elm::inhstruct
68 
69 #endif // ELM_INHSTRUCT_SORTEDBINTREE_H
elm::inhstruct::SortedBinTree::compare
virtual int compare(Node *node1, Node *node2)=0
elm::inhstruct::BinTree
Definition: BinTree.h:13
elm::inhstruct::SortedBinTree::visit
void visit(Visitor *visitor)
Definition: SortedBinTree.h:55
elm::inhstruct::SortedBinTree::clear
void clear(void)
Definition: SortedBinTree.h:63
elm::inhstruct::SortedBinTree::contains
bool contains(Node *node)
Definition: SortedBinTree.h:51
elm::inhstruct::BinTree::clear
void clear(void)
Definition: BinTree.h:106
elm
Definition: adapter.h:26
elm::inhstruct::SortedBinTree::search
void search(Visitor *visitor)
Definition: SortedBinTree.h:59
elm::inhstruct::BinTree::isEmpty
bool isEmpty(void) const
Definition: BinTree.h:81
elm::inhstruct::SortedBinTree::get
Node * get(Node *node)
Definition: inhstruct_SortedBinTree.cpp:80
elm::inhstruct::SortedBinTree::count
int count(void)
Definition: SortedBinTree.h:47
elm::inhstruct::BinTree::Node
Definition: BinTree.h:16
elm::inhstruct::SortedBinTree::~SortedBinTree
virtual ~SortedBinTree(void)
Definition: SortedBinTree.h:25
elm::inhstruct::BinTree::Visitor
Definition: BinTree.h:28
elm::io::right
IntFormat right(IntFormat fmt)
Definition: Output.h:264
elm::io::left
IntFormat left(IntFormat fmt)
Definition: Output.h:263
elm::inhstruct::SortedBinTree
Definition: SortedBinTree.h:15
elm::inhstruct::BinTree::count
int count(void) const
Definition: BinTree.h:87
elm::inhstruct::SortedBinTree::isEmpty
bool isEmpty(void)
Definition: SortedBinTree.h:43