Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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
bool isEmpty(void)
Definition: SortedBinTree.h:43
void search(Visitor *visitor)
Definition: SortedBinTree.h:59
virtual ~SortedBinTree(void)
Definition: SortedBinTree.h:25
bool isEmpty(void) const
Definition: BinTree.h:81
Definition: BinTree.h:13
bool contains(Node *node)
Definition: SortedBinTree.h:51
IntFormat right(IntFormat fmt)
Definition: Output.h:250
void visit(Visitor *visitor)
Definition: SortedBinTree.h:55
Definition: BinTree.h:28
int count(void) const
Definition: BinTree.h:87
Definition: BinTree.h:16
void clear(void)
Definition: SortedBinTree.h:63
void clear(void)
Definition: BinTree.h:106
IntFormat left(IntFormat fmt)
Definition: Output.h:249
int count(void)
Definition: SortedBinTree.h:47
virtual int compare(Node *node1, Node *node2)=0
Definition: SortedBinTree.h:15