import java.util.*;
/**
* Created by IntelliJ IDEA.
* User: me
* Date: 11.09.2006
* Time: 15:38:21
* To change this template use File | Settings | File Templates.
*/
private int size;
// **************************** INNER >>
private class ABLIterator
implements Iterator { private int off;
private int array;
private int pos;
public ABLIterator() {
off = 0;
pos = 0;
// Miss all empty arrays
for (array = 0; array < arrays.length; array++)
if (arrays[array].length > 0)
break;
}
public boolean hasNext() {
return off + pos < size();
}
if (!hasNext())
Object ret = arrays
[array
][pos++
];
while (pos >= arrays[array].length) {
off += arrays[array++].length;
pos = 0;
if (array >= arrays.length)
break;
}
return ret;
}
public void remove() {
}
}
// **************************** << INNER
public ArrayBunchList
(Object[][] arrays
) { this.
arrays =
(Object[][])arrays.
clone();
int s = 0;
for (int i = 0; i < arrays.length; i++) {
s += arrays[i].length;
}
size = s;
}
public int size() {
return size;
}
public Object get
(int index
) { int off = 0;
for (int i = 0; i < arrays.length; i++) {
if (index < off + arrays[i].length)
return arrays[i][index - off];
off += arrays[i].length;
}
}
int off = 0;
for (int i = 0; i < arrays.length; i++) {
if (index < off + arrays[i].length) {
Object ret = arrays
[i
][index - off
];
arrays[i][index - off] = value;
return ret;
}
off += arrays[i].length;
}
}
return new ABLIterator();
}
}