From fe2e3994513a8325cf6017ebfedea69b187e5db0 Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 16 Nov 2012 13:49:33 -0800 Subject: [PATCH] RegionIndex now extends Iterable. --- .../java/com/sk89q/worldguard/region/indices/FlatIndex.java | 5 +++++ .../sk89q/worldguard/region/indices/PriorityRTreeIndex.java | 5 +++++ .../com/sk89q/worldguard/region/indices/RegionIndex.java | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldguard/region/indices/FlatIndex.java b/src/main/java/com/sk89q/worldguard/region/indices/FlatIndex.java index ecd8e5a3..9e83b8de 100644 --- a/src/main/java/com/sk89q/worldguard/region/indices/FlatIndex.java +++ b/src/main/java/com/sk89q/worldguard/region/indices/FlatIndex.java @@ -107,4 +107,9 @@ public synchronized int size() { public void reindex() { // Whoo, nothing to do, because this index is so simple } + + @Override + public Iterator iterator() { + return regions.values().iterator(); + } } diff --git a/src/main/java/com/sk89q/worldguard/region/indices/PriorityRTreeIndex.java b/src/main/java/com/sk89q/worldguard/region/indices/PriorityRTreeIndex.java index aacde882..6b98103a 100644 --- a/src/main/java/com/sk89q/worldguard/region/indices/PriorityRTreeIndex.java +++ b/src/main/java/com/sk89q/worldguard/region/indices/PriorityRTreeIndex.java @@ -132,4 +132,9 @@ public void reindex() { tree.load(regions.values()); } + @Override + public Iterator iterator() { + return regions.values().iterator(); + } + } \ No newline at end of file diff --git a/src/main/java/com/sk89q/worldguard/region/indices/RegionIndex.java b/src/main/java/com/sk89q/worldguard/region/indices/RegionIndex.java index f43b2b60..aa473c13 100644 --- a/src/main/java/com/sk89q/worldguard/region/indices/RegionIndex.java +++ b/src/main/java/com/sk89q/worldguard/region/indices/RegionIndex.java @@ -38,7 +38,7 @@ * querying by ID. Any casing can be used when looking up an ID. Implementations do NOT * have to be thread-safe. */ -public interface RegionIndex { +public interface RegionIndex extends Iterable { /** * Queries the index for a list of {@link Region}s that contain the