use of ch.ethz.globis.phtree.v16.Node.BSTEntry in project phtree by tzaeschke.
the class PhTree16 method replace.
@Override
public boolean replace(long[] key, T oldValue, T newValue) {
if (getRoot() == null) {
return false;
}
Object o = getRoot();
while (true) {
Node currentNode = (Node) o;
long hcPos = posInArray(key, currentNode.getPostLen());
BSTEntry e = currentNode.getEntry(hcPos, key);
if (e == null) {
return false;
}
o = e.getValue();
if (!(o instanceof Node)) {
if (Objects.equals(maskNull(oldValue), o)) {
e.setValue(maskNull(newValue));
return true;
}
return false;
}
}
}
use of ch.ethz.globis.phtree.v16.Node.BSTEntry in project phtree by tzaeschke.
the class PhTree16 method putIfAbsent.
@Override
public T putIfAbsent(long[] key, T value) {
if (getRoot() == null) {
insertRoot(key, maskNull(value));
return null;
}
Object o = getRoot();
while (true) {
Node currentNode = (Node) o;
long hcPos = posInArray(key, currentNode.getPostLen());
BSTEntry e = currentNode.getEntry(hcPos, key);
if (e == null) {
increaseNrEntries();
currentNode.addEntry(hcPos, key, maskNull(value), this);
return null;
}
o = e.getValue();
if (!(o instanceof Node)) {
return unmaskNull(o);
}
}
}
use of ch.ethz.globis.phtree.v16.Node.BSTEntry in project phtree by tzaeschke.
the class BSTIteratorAll method nextEntry.
public BSTEntry nextEntry() {
if (!hasNextEntry()) {
throw new NoSuchElementException();
}
BSTEntry ret = nextValue;
findNext();
return ret;
}
use of ch.ethz.globis.phtree.v16.Node.BSTEntry in project phtree by tzaeschke.
the class BSTIteratorMask method nextEntry.
public BSTEntry nextEntry() {
if (!hasNextEntry()) {
throw new NoSuchElementException();
}
BSTEntry ret = nextValue;
findNext();
return ret;
}
use of ch.ethz.globis.phtree.v16.Node.BSTEntry in project phtree by tzaeschke.
the class BSTreePage method findAndRemove.
public BSTEntry findAndRemove(long key, long[] kdKey, Node node, PhTree16.UpdateInfo ui) {
// The stored value[i] is the min-values of the according page[i+1}
int pos = binarySearchInnerNode(key);
// read page before that value
BSTreePage page = subPages[pos];
BSTEntry result;
if (page.isLeaf()) {
result = page.remove(key, kdKey, node, ui);
checkUnderflowSubpageLeaf(pos, node);
} else {
result = page.findAndRemove(key, kdKey, node, ui);
handleUnderflowSubInner(pos);
}
return result;
}
Aggregations