Finished ArrayList

-Finished: Missing Methods to ArrayList
-Added: Stack.class
-Added: Trimmable interface
This commit is contained in:
2020-11-28 15:05:28 +01:00
parent 737c87daca
commit 0af3266f02
11 changed files with 231 additions and 18 deletions
@@ -1,5 +1,6 @@
package speiger.src.collections.PACKAGE.utils;
import java.util.Iterator;
import speiger.src.collections.PACKAGE.collections.ITERATOR;
public class ITERATORS
@@ -12,6 +13,22 @@ public class ITERATORS
return new ArrayIteratorBRACES(a, start, end);
}
public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, Iterator<? extends CLASS_TYPE> i) {
return unwrap(a, i, 0, a.length);
}
public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, Iterator<? extends CLASS_TYPE> i, int offset) {
return unwrap(a, i, offset, a.length);
}
public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, Iterator<? extends CLASS_TYPE> 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<max && i.hasNext();index++) a[index+offset] = OBJ_TO_KEY(i.next());
return index;
}
public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i) {
return unwrap(a, i, 0, a.length);
}