use of org.drools.core.util.ObjectHashMap.ObjectEntry in project drools by kiegroup.
the class ObjectHashMapTest method testEmptyIterator.
@Test
public void testEmptyIterator() {
final ObjectHashMap map = new ObjectHashMap();
final Iterator it = map.iterator();
for (ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next()) {
fail("Map is empty, there should be no iteration");
}
}
use of org.drools.core.util.ObjectHashMap.ObjectEntry in project drools by kiegroup.
the class CompositeObjectSinkAdapter method getSinks.
public ObjectSink[] getSinks() {
if (this.sinks != null) {
return sinks;
}
ObjectSink[] sinks = new ObjectSink[size()];
int at = 0;
if (this.hashedFieldIndexes != null) {
// Iterate the FieldIndexes to see if any are hashed
for (FieldIndex fieldIndex = this.hashedFieldIndexes.getFirst(); fieldIndex != null; fieldIndex = fieldIndex.getNext()) {
if (!fieldIndex.isHashed()) {
continue;
}
// this field is hashed so set the existing hashKey and see if there is a sink for it
final int index = fieldIndex.getIndex();
final Iterator it = this.hashedSinkMap.newIterator();
for (ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next()) {
HashKey hashKey = (HashKey) entry.getKey();
if (hashKey.getIndex() == index) {
sinks[at++] = (ObjectSink) entry.getValue();
}
}
}
}
if (this.hashableSinks != null) {
for (ObjectSinkNode sink = this.hashableSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode()) {
sinks[at++] = sink;
}
}
if (this.otherSinks != null) {
for (ObjectSinkNode sink = this.otherSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode()) {
sinks[at++] = sink;
}
}
this.sinks = sinks;
return sinks;
}
use of org.drools.core.util.ObjectHashMap.ObjectEntry in project drools by kiegroup.
the class CompositeObjectSinkAdapter method reIndexNodes.
public void reIndexNodes() {
sinksMap = new HashMap<>();
if (this.otherSinks != null) {
for (ObjectSinkNode sink = this.otherSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode()) {
sinksMap.put(sink, sink);
}
}
if (this.hashableSinks != null) {
for (ObjectSinkNode sink = this.hashableSinks.getFirst(); sink != null; sink = sink.getNextObjectSinkNode()) {
sinksMap.put(sink, sink);
}
}
if (this.hashedSinkMap != null) {
final Iterator it = this.hashedSinkMap.newIterator();
for (ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next()) {
final ObjectSink sink = (ObjectSink) entry.getValue();
sinksMap.put(sink, sink);
}
}
}
use of org.drools.core.util.ObjectHashMap.ObjectEntry in project drools by kiegroup.
the class JavaIteratorAdapter method setNext.
private void setNext() {
ObjectEntry entry = null;
while (entry == null) {
entry = (ObjectEntry) this.iterator.next();
if (entry == null) {
break;
}
if (this.filter != null) {
Object object = ((InternalFactHandle) entry.getKey()).getObject();
if (this.filter.accept(object) == false) {
entry = null;
}
}
}
this.nextEntry = entry;
// this.nextHandle = handle;
// this.nextObject = object;
}
use of org.drools.core.util.ObjectHashMap.ObjectEntry in project drools by kiegroup.
the class ObjectHashSet method contains.
public boolean contains(final Object value) {
final int hashCode = this.comparator.hashCodeOf(value);
final int index = indexOf(hashCode, this.table.length);
ObjectEntry current = (ObjectEntry) this.table[index];
while (current != null) {
if (hashCode == current.cachedHashCode && this.comparator.equal(value, current.value)) {
return true;
}
current = (ObjectEntry) current.getNext();
}
return false;
}
Aggregations