API reference / @jsprismarine/features / JavaHashSet
Class: JavaHashSet
Defined in: features/javaHashSet.ts:24
A HashSet<BlockPos> with Java's iteration order.
A tree feature collects its logs, leaves and roots into HashSets, and the decorators then walk them. Java's iteration order is the table's bucket order, so which log gets the beehive and which leaf grows a vine depend on BlockPos.hashCode and on how far the table has grown, not on the order the tree placed them. A Set in insertion order would produce a different, equally valid, but visibly different tree.
Only insertion, membership and iteration are implemented, which is all the tree code uses. The bucket order is derived at iteration time from the insertion log, which gives the same answer as replaying Java's resizes: a resize rehashes every entry and keeps the relative order inside each new bucket.
Implements
Iterable<BlockPos>
Constructors
Constructor
new JavaHashSet():
JavaHashSet
Returns
JavaHashSet
Accessors
size
Get Signature
get size():
number
Defined in: features/javaHashSet.ts:31
How many positions the set holds.
Returns
number
Methods
[iterator]()
[iterator]():
Generator<BlockPos>
Defined in: features/javaHashSet.ts:53
Iterates in Java's bucket order: table slot ascending, insertion order inside a slot.
Returns
Generator<BlockPos>
Implementation of
Iterable.[iterator]
add()
add(
position):void
Defined in: features/javaHashSet.ts:36
Adds a position, ignoring a repeat.
Parameters
position
Returns
void
has()
has(
position):boolean
Defined in: features/javaHashSet.ts:48
Answers whether a position is in the set.
Parameters
position
Returns
boolean
sortedByY()
sortedByY():
BlockPos[]
Defined in: features/javaHashSet.ts:66
Returns the contents sorted by y, stably, which is what a tree decorator reads.
Returns
BlockPos[]
toArray()
toArray():
BlockPos[]
Defined in: features/javaHashSet.ts:61
Returns the contents as an array in Java's iteration order.
Returns
BlockPos[]