-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMutableArray.java
More file actions
56 lines (41 loc) · 1.23 KB
/
MutableArray.java
File metadata and controls
56 lines (41 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package javasabr.rlib.collections.array;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.function.Consumer;
import java.util.function.IntFunction;
import java.util.stream.Stream;
import javasabr.rlib.collections.array.impl.DefaultMutableArray;
public interface MutableArray<E> extends Array<E>, Collection<E> {
static <E> MutableArray<E> ofType(Class<? super E> type) {
return new DefaultMutableArray<>(type);
}
boolean addAll(Array<? extends E> array);
default boolean addAll(MutableArray<? extends E> array) {
return addAll((Array<? extends E>) array);
}
boolean addAll(E[] array);
/**
* @return the element previously at the specified position
*/
E remove(int index);
void replace(int index, E element);
@Override
Stream<E> stream();
@Override
default <T> T[] toArray(IntFunction<T[]> generator) {
return Collection.super.toArray(generator);
}
@Override
default Iterator<E> iterator() {
return Array.super.iterator();
}
@Override
default void forEach(Consumer<? super E> action) {
Array.super.forEach(action);
}
@Override
UnsafeMutableArray<E> asUnsafe();
void sort();
void sort(Comparator<E> comparator);
}