~ubuntu-branches/ubuntu/maverick/hsqldb/maverick

« back to all changes in this revision

Viewing changes to src/org/hsqldb/BaseMemoryNode.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-09-26 11:47:49 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060926114749-3jd0utm7w21x1iqt
Tags: 1.8.0.5-2ubuntu1
* Synchronise with Debian unstable; remaining changes:
  - build using java-gcj-compat.
* libhsqldb-java: Add gij as alternative dependency.
* Build a libhsqldb-java-gcj package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
 */
65
65
 
66
66
 
67
 
package org.hsqldb;
68
 
 
69
 
import java.io.IOException;
70
 
 
71
 
import org.hsqldb.rowio.RowOutputInterface;
72
 
 
73
 
/**
74
 
 *  Common MEMORY and TEXT table node implementation. Nodes are always in
75
 
 *  memory so an Object reference is used to access the other Nodes in the
76
 
 *  AVL tree.
77
 
 *
78
 
 *  New class derived from the Hypersonic code
79
 
 *
80
 
 * @author Thomas Mueller (Hypersonic SQL Group)
81
 
 * @version    1.7.2
82
 
 * @since Hypersonic SQL
83
 
 */
84
 
abstract class BaseMemoryNode extends Node {
85
 
 
86
 
    protected Node nLeft;
87
 
    protected Node nRight;
88
 
    protected Node nParent;
89
 
 
90
 
    void delete() {
91
 
        iBalance = -2;
92
 
        nLeft    = nRight = nParent = null;
93
 
    }
94
 
 
95
 
    Node getLeft() throws HsqlException {
96
 
 
97
 
        if (Trace.DOASSERT) {
98
 
            Trace.doAssert(iBalance != -2);
99
 
        }
100
 
 
101
 
        return nLeft;
102
 
    }
103
 
 
104
 
    void setLeft(Node n) throws HsqlException {
105
 
 
106
 
        if (Trace.DOASSERT) {
107
 
            Trace.doAssert(iBalance != -2);
108
 
        }
109
 
 
110
 
        nLeft = n;
111
 
    }
112
 
 
113
 
    Node getRight() throws HsqlException {
114
 
 
115
 
        if (Trace.DOASSERT) {
116
 
            Trace.doAssert(iBalance != -2);
117
 
        }
118
 
 
119
 
        return nRight;
120
 
    }
121
 
 
122
 
    void setRight(Node n) throws HsqlException {
123
 
 
124
 
        if (Trace.DOASSERT) {
125
 
            Trace.doAssert(iBalance != -2);
126
 
        }
127
 
 
128
 
        nRight = n;
129
 
    }
130
 
 
131
 
    Node getParent() throws HsqlException {
132
 
 
133
 
        if (Trace.DOASSERT) {
134
 
            Trace.doAssert(iBalance != -2);
135
 
        }
136
 
 
137
 
        return nParent;
138
 
    }
139
 
 
140
 
    boolean isRoot() {
141
 
        return nParent == null;
142
 
    }
143
 
 
144
 
    void setParent(Node n) throws HsqlException {
145
 
 
146
 
        if (Trace.DOASSERT) {
147
 
            Trace.doAssert(iBalance != -2);
148
 
        }
149
 
 
150
 
        nParent = n;
151
 
    }
152
 
 
153
 
    void setBalance(int b) throws HsqlException {
154
 
 
155
 
        if (Trace.DOASSERT) {
156
 
            Trace.doAssert(iBalance != -2);
157
 
        }
158
 
 
159
 
        iBalance = b;
160
 
    }
161
 
 
162
 
    boolean isFromLeft() throws HsqlException {
163
 
 
164
 
        if (this.isRoot()) {
165
 
            return true;
166
 
        }
167
 
 
168
 
        Node parent = getParent();
169
 
 
170
 
        if (Trace.DOASSERT) {
171
 
            Trace.doAssert(parent != null);
172
 
        }
173
 
 
174
 
        return equals(parent.getLeft());
175
 
    }
176
 
 
177
 
    boolean equals(Node n) {
178
 
        return n == this;
179
 
    }
180
 
 
181
 
    void write(RowOutputInterface out) throws IOException {}
182
 
}
 
67
package org.hsqldb;
 
68
 
 
69
import java.io.IOException;
 
70
 
 
71
import org.hsqldb.rowio.RowOutputInterface;
 
72
 
 
73
/**
 
74
 *  Common MEMORY and TEXT table node implementation. Nodes are always in
 
75
 *  memory so an Object reference is used to access the other Nodes in the
 
76
 *  AVL tree.
 
77
 *
 
78
 *  New class derived from the Hypersonic code
 
79
 *
 
80
 * @author Thomas Mueller (Hypersonic SQL Group)
 
81
 * @version    1.7.2
 
82
 * @since Hypersonic SQL
 
83
 */
 
84
abstract class BaseMemoryNode extends Node {
 
85
 
 
86
    protected Node nLeft;
 
87
    protected Node nRight;
 
88
    protected Node nParent;
 
89
 
 
90
    void delete() {
 
91
        iBalance = -2;
 
92
        nLeft    = nRight = nParent = null;
 
93
    }
 
94
 
 
95
    Node getLeft() throws HsqlException {
 
96
 
 
97
        if (Trace.DOASSERT) {
 
98
            Trace.doAssert(iBalance != -2);
 
99
        }
 
100
 
 
101
        return nLeft;
 
102
    }
 
103
 
 
104
    void setLeft(Node n) throws HsqlException {
 
105
 
 
106
        if (Trace.DOASSERT) {
 
107
            Trace.doAssert(iBalance != -2);
 
108
        }
 
109
 
 
110
        nLeft = n;
 
111
    }
 
112
 
 
113
    boolean isLeft(Node node) throws HsqlException {
 
114
        return nLeft == node;
 
115
    }
 
116
 
 
117
    boolean isRight(Node node) throws HsqlException {
 
118
        return nRight == node;
 
119
    }
 
120
 
 
121
    Node getRight() throws HsqlException {
 
122
 
 
123
        if (Trace.DOASSERT) {
 
124
            Trace.doAssert(iBalance != -2);
 
125
        }
 
126
 
 
127
        return nRight;
 
128
    }
 
129
 
 
130
    void setRight(Node n) throws HsqlException {
 
131
 
 
132
        if (Trace.DOASSERT) {
 
133
            Trace.doAssert(iBalance != -2);
 
134
        }
 
135
 
 
136
        nRight = n;
 
137
    }
 
138
 
 
139
    Node getParent() throws HsqlException {
 
140
 
 
141
        if (Trace.DOASSERT) {
 
142
            Trace.doAssert(iBalance != -2);
 
143
        }
 
144
 
 
145
        return nParent;
 
146
    }
 
147
 
 
148
    boolean isRoot() {
 
149
        return nParent == null;
 
150
    }
 
151
 
 
152
    void setParent(Node n) throws HsqlException {
 
153
 
 
154
        if (Trace.DOASSERT) {
 
155
            Trace.doAssert(iBalance != -2);
 
156
        }
 
157
 
 
158
        nParent = n;
 
159
    }
 
160
 
 
161
    void setBalance(int b) throws HsqlException {
 
162
 
 
163
        if (Trace.DOASSERT) {
 
164
            Trace.doAssert(iBalance != -2);
 
165
        }
 
166
 
 
167
        iBalance = b;
 
168
    }
 
169
 
 
170
    boolean isFromLeft() throws HsqlException {
 
171
 
 
172
        if (this.isRoot()) {
 
173
            return true;
 
174
        }
 
175
 
 
176
        Node parent = getParent();
 
177
 
 
178
        if (Trace.DOASSERT) {
 
179
            Trace.doAssert(parent != null);
 
180
        }
 
181
 
 
182
        return equals(parent.getLeft());
 
183
    }
 
184
 
 
185
    boolean equals(Node n) {
 
186
        return n == this;
 
187
    }
 
188
 
 
189
    void write(RowOutputInterface out) throws IOException {}
 
190
}