ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/ccscs20/NullNode.hpp
Revision: 13
Committed: 2004-05-15T14:59:28-07:00 (21 years, 1 month ago) by Douglas Thrift
File size: 1350 byte(s)
Log Message:
Take that David!

File Contents

# Content
1 // Null Node
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #ifndef _NullNode_hpp_
8 #define _NullNode_hpp_
9
10 #include "Node.hpp"
11
12 template<typename Type>
13 class NullNode : public Node<Type>
14 {
15 public:
16 void setNext(NullNode<Type>* next) { this->next = dynamic_cast<Node<Type>*>(next); }
17 void setPrevious(NullNode<Type>* previous) { this->previous = dynamic_cast<Node<Type>*>(previous); }
18 bool contains(const Type& value, Node<Type>* end, bool forward);
19 void remove(const Type& value, Node<Type>* end, bool forward);
20 void accept(Visitor<Type>* visitor, Node<Type>* end, bool forward);
21 };
22
23 template<typename Type>
24 bool NullNode<Type>::contains(const Type& value, Node<Type>* end, bool forward)
25 {
26 Node<Type>* another = forward ? Node<Type>::next : Node<Type>::previous;
27
28 if (end == this) return false; else return another->contains(value, end, forward);
29 }
30
31 template<typename Type>
32 void NullNode<Type>::remove(const Type& value, Node<Type>* end, bool forward)
33 {
34 Node<Type>* another = forward ? Node<Type>::next : Node<Type>::previous;
35
36 if (end != this) another->remove(value, end, forward);
37 }
38
39 template<typename Type>
40 void NullNode<Type>::accept(Visitor<Type>* visitor, Node<Type>* end, bool forward)
41 {
42 Node<Type>* another = forward ? Node<Type>::next : Node<Type>::previous;
43
44 if (end != this) another->accept(visitor, end, forward);
45 }
46
47 #endif // _NullNode_hpp_

Properties

Name Value
svn:eol-style native
svn:keywords Id