project: Add back NodeHashTable.getNodes() for compatability
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package net.runelite.api;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A data structure that uses a hash function to compute an index into an
|
||||
* array of buckets from which node objects can be quickly obtained.
|
||||
@@ -13,4 +15,11 @@ public interface HashTable<T extends Node> extends Iterable<T>
|
||||
* @return the associated node
|
||||
*/
|
||||
T get(long value);
|
||||
|
||||
/**
|
||||
* Gets a collection of all nodes stored in this table.
|
||||
*
|
||||
* @return the nodes stored
|
||||
*/
|
||||
Collection<T> getNodes();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,38 @@
|
||||
package net.runelite.mixins;
|
||||
|
||||
import net.runelite.api.Node;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
import net.runelite.rs.api.RSNodeHashTable;
|
||||
|
||||
@Mixin(RSNodeHashTable.class)
|
||||
public abstract class RSNodeHashTableMixin implements RSNodeHashTable
|
||||
{}
|
||||
{
|
||||
@Inject
|
||||
@Override
|
||||
public Collection<Node> getNodes()
|
||||
{
|
||||
// Copied in RSWidgetMixin.getParentId to reduce allocations
|
||||
List<Node> nodes = new ArrayList<Node>();
|
||||
|
||||
Node[] buckets = getBuckets();
|
||||
for (int i = 0; i < buckets.length; ++i)
|
||||
{
|
||||
Node node = buckets[i];
|
||||
|
||||
// It looks like the first node in the bucket is always
|
||||
// a sentinel
|
||||
Node cur = node.getNext();
|
||||
while (cur != node)
|
||||
{
|
||||
nodes.add(cur);
|
||||
cur = cur.getNext();
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user