package speiger.src.collections.PACKAGE.utils; import java.util.Iterator; import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR; public class ITERATORS { public static final EmptyIterator NO_GENERIC_TYPE EMPTY = new EmptyIteratorBRACES(); public static GENERIC_BRACES EmptyIterator KEY_GENERIC_TYPE emptyIterator() { #if TYPE_OBJECT return (EmptyIterator)EMPTY; #else return EMPTY; #endif } public static GENERIC_BRACES ITERATOR KEY_GENERIC_TYPE unmodifiable(ITERATOR KEY_GENERIC_TYPE iterator) { return new UnmodifiableIteratorBRACES(iterator); } public static GENERIC_BRACES LIST_ITERATOR KEY_GENERIC_TYPE unmodifiable(LIST_ITERATOR KEY_GENERIC_TYPE iterator) { return new UnmodifiableListIteratorBRACES(iterator); } public static GENERIC_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE[] a) { return wrap(a, 0, a.length); } public static GENERIC_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE[] a, int start, int end) { return new ArrayIteratorBRACES(a, start, end); } public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, Iterator i) { return unwrap(a, i, 0, a.length); } public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, Iterator i, int offset) { return unwrap(a, i, offset, a.length); } public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, Iterator i, int offset, int max) { if(max < 0) throw new IllegalStateException("The max size is smaller then 0"); if(offset + max >= a.length) throw new IllegalStateException("largest array index exceeds array size"); int index = 0; for(;index= a.length) throw new IllegalStateException("largest array index exceeds array size"); int index = 0; for(;index= a.length) throw new IllegalStateException("largest array index exceeds array size"); int index = 0; for(;index