1 | /* |
2 | * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, |
3 | * and the EPL 1.0 (http://h2database.com/html/license.html). |
4 | * Initial Developer: H2 Group |
5 | */ |
6 | package org.h2.index; |
7 | |
8 | import org.h2.result.Row; |
9 | |
10 | /** |
11 | * Represents a index node of a tree index. |
12 | */ |
13 | class TreeNode { |
14 | |
15 | /** |
16 | * The balance. For more information, see the AVL tree documentation. |
17 | */ |
18 | int balance; |
19 | |
20 | /** |
21 | * The left child node or null. |
22 | */ |
23 | TreeNode left; |
24 | |
25 | /** |
26 | * The right child node or null. |
27 | */ |
28 | TreeNode right; |
29 | |
30 | /** |
31 | * The parent node or null if this is the root node. |
32 | */ |
33 | TreeNode parent; |
34 | |
35 | /** |
36 | * The row. |
37 | */ |
38 | final Row row; |
39 | |
40 | TreeNode(Row row) { |
41 | this.row = row; |
42 | } |
43 | |
44 | /** |
45 | * Check if this node is the left child of its parent. This method returns |
46 | * true if this is the root node. |
47 | * |
48 | * @return true if this node is the root or a left child |
49 | */ |
50 | boolean isFromLeft() { |
51 | return parent == null || parent.left == this; |
52 | } |
53 | |
54 | } |