summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/DeepEnumeration.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/DeepEnumeration.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/DeepEnumeration.java')
-rw-r--r--NET/worlds/scape/DeepEnumeration.java114
1 files changed, 114 insertions, 0 deletions
diff --git a/NET/worlds/scape/DeepEnumeration.java b/NET/worlds/scape/DeepEnumeration.java
new file mode 100644
index 0000000..060d71e
--- /dev/null
+++ b/NET/worlds/scape/DeepEnumeration.java
@@ -0,0 +1,114 @@
+package NET.worlds.scape;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+public class DeepEnumeration<K> implements Enumeration<K> {
+ Vector<SuperRoot> roots = new Vector<SuperRoot>();
+ Vector<Vector<K>> vectors = new Vector<Vector<K>>();
+ Vector<K> currentVector = null;
+ int currentIndex = -1;
+ SuperRoot nextValue = null;
+ protected boolean valueRetrieved = true;
+
+ public DeepEnumeration(SuperRoot o) {
+ this.addChildElement(o);
+ }
+
+ public DeepEnumeration(Vector<K> v) {
+ this.addChildVector(v);
+ }
+
+ public DeepEnumeration(Enumeration<K> e) {
+ this.addChildEnumeration(e);
+ }
+
+ public DeepEnumeration() {
+ }
+
+ @Override
+ public boolean hasMoreElements() {
+ if (this.valueRetrieved) {
+ this.getNextElement();
+ }
+
+ return this.nextValue != null;
+ }
+
+ @Override
+ public K nextElement() {
+ if (this.valueRetrieved) {
+ this.getNextElement();
+ }
+
+ this.valueRetrieved = true;
+ return (K)this.nextValue;
+ }
+
+ protected void getNextElement() {
+ this.valueRetrieved = false;
+ if (!this.roots.isEmpty()) {
+ this.nextValue = this.roots.elementAt(this.roots.size() - 1);
+ this.roots.removeElementAt(this.roots.size() - 1);
+
+ assert this.nextValue != null;
+
+ this.nextValue.getChildren(this);
+ } else if (this.currentIndex >= 0) {
+ try {
+ this.nextValue = (SuperRoot)this.currentVector.elementAt(this.currentIndex--);
+ } catch (ArrayIndexOutOfBoundsException var2) {
+ this.currentIndex = this.currentVector.size() - 1;
+ this.getNextElement();
+ }
+
+ assert this.nextValue != null;
+
+ this.nextValue.getChildren(this);
+ } else if (!this.vectors.isEmpty()) {
+ this.currentVector = this.vectors.elementAt(this.vectors.size() - 1);
+ this.currentIndex = this.currentVector.size() - 1;
+ this.vectors.removeElementAt(this.vectors.size() - 1);
+ this.getNextElement();
+ } else {
+ this.nextValue = null;
+ }
+ }
+
+ public void addChildVector(Vector<K> eventHandlers) {
+ assert eventHandlers != null;
+
+ this.vectors.addElement(eventHandlers);
+ }
+
+ public void addChildEnumeration(Enumeration<K> e) {
+ assert e != null;
+
+ while (e.hasMoreElements()) {
+ this.addChildElement(e.nextElement());
+ }
+ }
+
+ public void addChildVectorWithNulls(Vector<K> v) {
+ assert v != null;
+
+ for (int i = v.size() - 1; i >= 0; i--) {
+ Object obj = v.elementAt(i--);
+ if (obj != null) {
+ this.addChildElement(obj);
+ }
+ }
+ }
+
+ public void addChildElement(Object o) {
+ assert o != null;
+
+ this.roots.addElement((SuperRoot)o);
+ }
+
+ public void addChildVectorAction(Vector<K> actions) {
+ assert actions != null;
+
+ this.vectors.addElement(actions);
+ }
+}