public class ChunkHashTable extends java.lang.Object implements ConcurrentRegionIndex
| Modifier and Type | Class and Description |
|---|---|
static class |
ChunkHashTable.Factory
A factory for instances of
ChunkHashCache. |
| Constructor and Description |
|---|
ChunkHashTable(RegionIndex index,
java.lang.String name)
Create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(ProtectedRegion region)
Add a region to this index, replacing any existing one with the same
name (equality determined using
Normal). |
void |
addAll(java.util.Collection<ProtectedRegion> regions)
Add a list of regions to this index, replacing any existing one
with the same name (equality determined using
Normal). |
void |
apply(java.util.function.Predicate<ProtectedRegion> consumer)
Apply the given predicate to all the regions in the index
until there are no more regions or the predicate returns false.
|
void |
applyContaining(com.sk89q.worldedit.math.BlockVector3 position,
java.util.function.Predicate<ProtectedRegion> consumer)
Apply the given predicate to all regions that contain the given
position until there are no more regions or the predicate returns false.
|
void |
applyIntersecting(ProtectedRegion region,
java.util.function.Predicate<ProtectedRegion> consumer)
Apply the given predicate to all regions that intersect the given
region until there are no more regions or the predicate returns false.
|
boolean |
awaitCompletion(long timeout,
java.util.concurrent.TimeUnit unit)
Waits until all currently executing background tasks complete.
|
void |
bias(com.sk89q.worldedit.math.BlockVector2 chunkPosition)
Bias the given chunk for faster lookups (put it in a hash table, etc.).
|
void |
biasAll(java.util.Collection<com.sk89q.worldedit.math.BlockVector2> chunkPositions)
Bias the given chunk for faster lookups (put it in a hash table, etc.).
|
boolean |
contains(java.lang.String id)
Test whether the index contains a region named by the given name
(equality determined using
Normal). |
void |
forget(com.sk89q.worldedit.math.BlockVector2 chunkPosition)
No longer bias the given chunk for faster lookup.
|
void |
forgetAll()
Clearly all extra cache data created by any calls to
RegionIndex.bias(BlockVector2). |
ProtectedRegion |
get(java.lang.String id)
Get the region named by the given name (equality determined using
Normal). |
RegionDifference |
getAndClearDifference()
Get the list of changed or removed regions since last call and
clear those lists.
|
boolean |
isDirty()
Tests whether changes have been made.
|
java.util.Set<ProtectedRegion> |
remove(java.lang.String id,
RemovalStrategy strategy)
Remove a region from the index with the given name.
|
void |
setDirty(boolean dirty)
Set whether changes have been made.
|
void |
setDirty(RegionDifference difference)
Set the index to be dirty using the given difference.
|
int |
size()
Return the number of regions in the index.
|
java.util.Collection<ProtectedRegion> |
values()
Get an unmodifiable collection of regions stored in this index.
|
public ChunkHashTable(RegionIndex index, java.lang.String name)
index - the indexname - public boolean awaitCompletion(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
timeout - the maximum time to waitunit - the time unit of the timeout argumenttrue if this executor terminated and
false if the timeout elapsed before terminationjava.lang.InterruptedException - on interruptionpublic void bias(com.sk89q.worldedit.math.BlockVector2 chunkPosition)
RegionIndexImplementations may choose to do nothing.
bias in interface RegionIndexchunkPosition - the chunk positionpublic void biasAll(java.util.Collection<com.sk89q.worldedit.math.BlockVector2> chunkPositions)
RegionIndexImplementations may choose to do nothing.
biasAll in interface RegionIndexchunkPositions - the chunk positionpublic void forget(com.sk89q.worldedit.math.BlockVector2 chunkPosition)
RegionIndexforget in interface RegionIndexchunkPosition - the chunk positionpublic void forgetAll()
RegionIndexRegionIndex.bias(BlockVector2).forgetAll in interface RegionIndexpublic void add(ProtectedRegion region)
RegionIndexNormal).
The parents of the region will also be added to the index.
add in interface RegionIndexregion - the regionpublic void addAll(java.util.Collection<ProtectedRegion> regions)
RegionIndexNormal).
The parents of the region will also be added to the index.
addAll in interface RegionIndexregions - a collections of regionspublic java.util.Set<ProtectedRegion> remove(java.lang.String id, RemovalStrategy strategy)
RegionIndexremove in interface RegionIndexid - the name of the regionstrategy - what to do with childrenidpublic boolean contains(java.lang.String id)
RegionIndexNormal).contains in interface RegionIndexid - the name of the region@Nullable public ProtectedRegion get(java.lang.String id)
RegionIndexNormal).get in interface RegionIndexid - the name of the regionnullpublic void apply(java.util.function.Predicate<ProtectedRegion> consumer)
RegionIndexapply in interface RegionIndexconsumer - a predicate that returns true to continue iteratingpublic void applyContaining(com.sk89q.worldedit.math.BlockVector3 position,
java.util.function.Predicate<ProtectedRegion> consumer)
RegionIndexapplyContaining in interface RegionIndexposition - the positionconsumer - a predicate that returns true to continue iteratingpublic void applyIntersecting(ProtectedRegion region, java.util.function.Predicate<ProtectedRegion> consumer)
RegionIndexapplyIntersecting in interface RegionIndexregion - the intersecting regionconsumer - a predicate that returns true to continue iteratingpublic int size()
RegionIndexsize in interface RegionIndexpublic RegionDifference getAndClearDifference()
RegionIndexgetAndClearDifference in interface RegionIndexpublic void setDirty(RegionDifference difference)
RegionIndexsetDirty in interface RegionIndexdifference - the differencepublic java.util.Collection<ProtectedRegion> values()
RegionIndexvalues in interface RegionIndexpublic boolean isDirty()
ChangeTrackedisDirty in interface ChangeTrackedpublic void setDirty(boolean dirty)
ChangeTrackedsetDirty in interface ChangeTrackeddirty - a new dirty state