Class PriorityRTreeIndex

java.lang.Object
com.sk89q.worldguard.protection.managers.index.HashMapIndex
com.sk89q.worldguard.protection.managers.index.PriorityRTreeIndex
All Implemented Interfaces:
ConcurrentRegionIndex, RegionIndex, ChangeTracked

public class PriorityRTreeIndex extends HashMapIndex
An implementation of an index that uses HashMapIndex for queries by region name and a priority R-tree for spatial queries.

At the moment, the R-tree is only utilized for the applyContaining(BlockVector3, Predicate) method, and the underlying hash map-based index is used for the other spatial queries. In addition, every modification to the index requires the entire R-tree to be rebuilt, although this operation is reasonably quick.

This implementation is as thread-safe as the underlying HashMapIndex, although spatial queries may lag behind changes for very brief periods of time as the tree is rebuilt.

  • Constructor Details

    • PriorityRTreeIndex

      public PriorityRTreeIndex()
  • Method Details

    • rebuildIndex

      protected void rebuildIndex()
      Description copied from class: HashMapIndex
      Called to rebuild the index after changes.
      Overrides:
      rebuildIndex in class HashMapIndex
    • applyContaining

      public void applyContaining(com.sk89q.worldedit.math.BlockVector3 position, Predicate<ProtectedRegion> consumer)
      Description copied from interface: RegionIndex
      Apply the given predicate to all regions that contain the given position until there are no more regions or the predicate returns false.
      Specified by:
      applyContaining in interface RegionIndex
      Overrides:
      applyContaining in class HashMapIndex
      Parameters:
      position - the position
      consumer - a predicate that returns true to continue iterating
    • applyIntersecting

      public void applyIntersecting(ProtectedRegion region, Predicate<ProtectedRegion> consumer)
      Description copied from interface: RegionIndex
      Apply the given predicate to all regions that intersect the given region until there are no more regions or the predicate returns false.
      Specified by:
      applyIntersecting in interface RegionIndex
      Overrides:
      applyIntersecting in class HashMapIndex
      Parameters:
      region - the intersecting region
      consumer - a predicate that returns true to continue iterating