1 6 package com.jofti.btree; 7 8 9 10 11 12 18 abstract class AbstractLeafNode extends Node implements Leaf { 19 20 21 protected NodeLink nextNode = null; 22 23 protected IndexNodeEntry parentKey = null; 24 25 protected boolean deleted = false; 26 27 protected Comparable rightValue; 28 29 32 33 34 35 AbstractLeafNode() { 36 } 37 38 43 protected void resetNextNode() { 44 if (nextNode != null && nextNode.getNode() != null 45 && nextNode.getNode().isDeleted()) { 46 nextNode = nextNode.getNode().getLinkNode(); 47 } 48 } 49 50 51 52 62 protected LeafNodeEntry indexedBinaryRetrieve(Object [] list1, Object obj) { 63 int i = 0; 64 int size = entryNumber; 65 for (int j = size- 1; i <= j;) { 66 int k = i + j >> 1; 67 LeafNodeEntry obj1 = (LeafNodeEntry)list1[k]; 68 int l = obj1.getValue().compareTo(obj); 69 if (l < 0) 70 i = k + 1; 71 else if (l > 0) 72 j = k - 1; 73 else 74 return obj1; 75 } 76 77 return null; 78 } 79 80 85 public NodeLink getLinkNode() { 86 87 return nextNode; 88 } 89 90 95 public void setLinkNode(NodeLink node) { 96 this.nextNode = node; 97 98 } 99 100 105 public boolean isDeleted() { 106 return deleted; 107 } 108 109 113 public void setDeleted(boolean deleted) { 114 this.deleted = deleted; 115 } 116 117 118 121 public Comparable getRightValue() { 122 123 return rightValue; 124 } 125 126 129 public void setRightValue(Comparable value) { 130 this.rightValue = value; 131 132 } 133 134 135 136 137 138 141 public int getEntryNumber() { 142 return entryNumber; 143 } 144 145 146 149 public LeafNodeEntry getEntry(Comparable value) { 150 if (entryNumber ==0) 151 { 152 return null; 153 } 154 155 157 return indexedBinaryRetrieve(realGetEntries(), value); 158 159 160 161 162 163 } 164 165 168 public boolean isUnderFull() { 169 if (entryNumber < BTree.getMaxNodeSize()) 170 { 171 return true; 172 } 173 return false; 174 } 175 176 177 178 179 protected abstract Object [] realGetEntries(); 180 181 182 183 186 public boolean isEmpty() { 187 return entryNumber ==0; 188 } 189 } | Popular Tags |