From c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 12 Feb 2026 22:33:32 -0800 Subject: Initial commit --- NET/worlds/scape/DeepEnumeration.java | 114 ++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 NET/worlds/scape/DeepEnumeration.java (limited to 'NET/worlds/scape/DeepEnumeration.java') 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 implements Enumeration { + Vector roots = new Vector(); + Vector> vectors = new Vector>(); + Vector currentVector = null; + int currentIndex = -1; + SuperRoot nextValue = null; + protected boolean valueRetrieved = true; + + public DeepEnumeration(SuperRoot o) { + this.addChildElement(o); + } + + public DeepEnumeration(Vector v) { + this.addChildVector(v); + } + + public DeepEnumeration(Enumeration 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 eventHandlers) { + assert eventHandlers != null; + + this.vectors.addElement(eventHandlers); + } + + public void addChildEnumeration(Enumeration e) { + assert e != null; + + while (e.hasMoreElements()) { + this.addChildElement(e.nextElement()); + } + } + + public void addChildVectorWithNulls(Vector 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 actions) { + assert actions != null; + + this.vectors.addElement(actions); + } +} -- cgit v1.2.3