2 // boo - an extensible programming language for the CLI
3 // Copyright (C) 2004 Rodrigo Barreto de Oliveira
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // Contact Information
24 import java
.util
.ArrayList
;
25 import java
.util
.Iterator
;
27 class xrange
implements Iterator
32 public xrange(int max
)
38 public boolean hasNext()
40 return _current
< _max
;
45 return new Integer(_current
++);
53 public class arrayperformance
55 public static final int items
= 2000000;
57 public static void main(String
[] args
)
64 private static void test()
66 Object
[] array
= new Object
[items
];
67 for (int i
= 0; i
< array
.length
; i
++)
69 array
[i
] = new Object();
72 ArrayList collect
= new ArrayList();
74 Iterator i
= new xrange(items
);
75 long start
= System
.currentTimeMillis();
78 int index
= ((Integer
)i
.next()).intValue();
79 collect
.add(array
[index
]);
81 System
.out
.println((System
.currentTimeMillis() - start
) + " elapsed.");