added CounterEnumeration
authoradam <adam@megacz.com>
Sun, 2 May 2004 08:13:40 +0000 (08:13 +0000)
committeradam <adam@megacz.com>
Sun, 2 May 2004 08:13:40 +0000 (08:13 +0000)
darcs-hash:20040502081340-5007d-cf596e0400662d929b67780c947cb8e48173c4e4.gz

src/org/ibex/util/CounterEnumeration.java [new file with mode: 0644]

diff --git a/src/org/ibex/util/CounterEnumeration.java b/src/org/ibex/util/CounterEnumeration.java
new file mode 100644 (file)
index 0000000..5a01f3e
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright (C) 2004 Adam Megacz <adam@ibex.org> all rights reserved.
+//
+// You may modify, copy, and redistribute this code under the terms of
+// the GNU Library Public License version 2.1, with the exception of
+// the portion of clause 6a after the semicolon (aka the "obnoxious
+// relink clause")
+package org.ibex.util;
+import java.util.*;
+
+public class CounterEnumeration implements Enumeration {
+    public final int max;
+    private int cur = 0;
+    public CounterEnumeration(int i) { max = i; }
+    public void reset() { cur = 0; }
+    public boolean hasMoreElements() { return cur < max; }
+    public Object nextElement() { return new Integer(cur++); }
+}