1
- package com .github . simonharmonicminor .juu .collection .immutable ;
1
+ package com .kirekov .juu .collection .immutable ;
2
2
3
- import com .github . simonharmonicminor .juu .monad .Try ;
3
+ import com .kirekov .juu .monad .Try ;
4
4
5
5
import java .io .Serializable ;
6
6
import java .util .*;
7
7
import java .util .function .*;
8
8
import java .util .stream .Stream ;
9
9
10
- import static com .github .simonharmonicminor .juu .collection .immutable .Immutable .listOfWithoutCloning ;
11
- import static com .github .simonharmonicminor .juu .collection .immutable .Immutable .setOf ;
12
- import static com .github .simonharmonicminor .juu .collection .immutable .ImmutableCollectionUtils .listEquals ;
13
- import static com .github .simonharmonicminor .juu .collection .immutable .ImmutableCollectionUtils .listToString ;
14
-
15
10
/**
16
11
* An immutable implementation of java native {@link ArrayList}.
17
12
*
@@ -107,7 +102,7 @@ public ImmutableList<T> slice(int fromIndex, int toIndex, int stepSize) {
107
102
newArrayList .add (get (fromNorm ));
108
103
fromNorm = nextValueFunc .apply (fromNorm );
109
104
}
110
- return listOfWithoutCloning (newArrayList );
105
+ return Immutable . listOfWithoutCloning (newArrayList );
111
106
}
112
107
113
108
@ Override
@@ -131,7 +126,7 @@ public ImmutableList<T> concatWith(Iterable<T> iterable) {
131
126
for (T t : iterable ) {
132
127
copy .add (t );
133
128
}
134
- return listOfWithoutCloning (copy );
129
+ return Immutable . listOfWithoutCloning (copy );
135
130
}
136
131
137
132
private static <R > R getValByIndex (ImmutableList <R > immutableList , int index ) {
@@ -149,7 +144,7 @@ public <R> ImmutableList<Pair<T, R>> zipWith(ImmutableList<R> list) {
149
144
R right = getValByIndex (list , i );
150
145
newArrayList .add (Pair .of (left , right ));
151
146
}
152
- return listOfWithoutCloning (newArrayList );
147
+ return Immutable . listOfWithoutCloning (newArrayList );
153
148
}
154
149
155
150
@ Override
@@ -158,7 +153,7 @@ public ImmutableList<Pair<T, T>> zipWithNext() {
158
153
for (int i = 0 ; i < size () - 1 ; i ++) {
159
154
newArrayList .add (Pair .of (get (i ), get (i + 1 )));
160
155
}
161
- return listOfWithoutCloning (newArrayList );
156
+ return Immutable . listOfWithoutCloning (newArrayList );
162
157
}
163
158
164
159
@ Override
@@ -168,7 +163,7 @@ public <R> ImmutableList<R> map(Function<? super T, ? extends R> mapper) {
168
163
for (T t : arrayList ) {
169
164
newList .add (mapper .apply (t ));
170
165
}
171
- return listOfWithoutCloning (newList );
166
+ return Immutable . listOfWithoutCloning (newList );
172
167
}
173
168
174
169
@ Override
@@ -178,7 +173,7 @@ public <R> ImmutableList<R> mapIndexed(BiFunction<Integer, ? super T, ? extends
178
173
for (int i = 0 ; i < arrayList .size (); i ++) {
179
174
newList .add (mapper .apply (i , arrayList .get (i )));
180
175
}
181
- return listOfWithoutCloning (newList );
176
+ return Immutable . listOfWithoutCloning (newList );
182
177
}
183
178
184
179
@ Override
@@ -189,7 +184,7 @@ public <R> ImmutableList<R> flatMap(Function<? super T, ? extends Iterable<R>> m
189
184
ImmutableArrayList <R > listElement = new ImmutableArrayList <>(mapper .apply (t ));
190
185
newList .addAll (listElement .arrayList );
191
186
}
192
- return listOfWithoutCloning (newList );
187
+ return Immutable . listOfWithoutCloning (newList );
193
188
}
194
189
195
190
@ Override
@@ -202,7 +197,7 @@ public <R> ImmutableList<R> flatMapIndexed(
202
197
new ImmutableArrayList <>(mapper .apply (i , arrayList .get (i )));
203
198
newList .addAll (listElement .arrayList );
204
199
}
205
- return listOfWithoutCloning (newList );
200
+ return Immutable . listOfWithoutCloning (newList );
206
201
}
207
202
208
203
@ Override
@@ -212,7 +207,7 @@ public ImmutableList<T> filter(Predicate<? super T> predicate) {
212
207
for (T t : arrayList ) {
213
208
if (predicate .test (t )) newList .add (t );
214
209
}
215
- return listOfWithoutCloning (newList );
210
+ return Immutable . listOfWithoutCloning (newList );
216
211
}
217
212
218
213
@ Override
@@ -222,7 +217,7 @@ public ImmutableList<T> filterIndexed(BiPredicate<Integer, ? super T> predicate)
222
217
for (int i = 0 ; i < arrayList .size (); i ++) {
223
218
if (predicate .test (i , arrayList .get (i ))) newList .add (arrayList .get (i ));
224
219
}
225
- return listOfWithoutCloning (newList );
220
+ return Immutable . listOfWithoutCloning (newList );
226
221
}
227
222
228
223
@ Override
@@ -238,7 +233,7 @@ public ImmutableList<T> sorted(Comparator<? super T> comparator) {
238
233
Objects .requireNonNull (comparator );
239
234
ArrayList <T > copy = new ArrayList <>(arrayList );
240
235
copy .sort (comparator );
241
- return listOfWithoutCloning (copy );
236
+ return Immutable . listOfWithoutCloning (copy );
242
237
}
243
238
244
239
@ Override
@@ -249,7 +244,7 @@ public ImmutableList<T> limit(int size) {
249
244
for (int i = 0 ; i < Math .min (size (), size ); i ++) {
250
245
newList .add (arrayList .get (i ));
251
246
}
252
- return listOfWithoutCloning (newList );
247
+ return Immutable . listOfWithoutCloning (newList );
253
248
}
254
249
255
250
@ Override
@@ -260,7 +255,7 @@ public ImmutableList<T> skip(int size) {
260
255
for (int i = Math .min (size , size ()); i < arrayList .size (); i ++) {
261
256
newList .add (arrayList .get (i ));
262
257
}
263
- return listOfWithoutCloning (newList );
258
+ return Immutable . listOfWithoutCloning (newList );
264
259
}
265
260
266
261
@ Override
@@ -286,7 +281,7 @@ public ImmutableList<T> toList() {
286
281
287
282
@ Override
288
283
public ImmutableSet <T > toSet () {
289
- return setOf (arrayList );
284
+ return Immutable . setOf (arrayList );
290
285
}
291
286
292
287
@ Override
@@ -306,7 +301,7 @@ public Iterator<T> iterator() {
306
301
307
302
@ Override
308
303
public boolean equals (Object o ) {
309
- return listEquals (this , o );
304
+ return ImmutableCollectionUtils . listEquals (this , o );
310
305
}
311
306
312
307
@ Override
@@ -316,6 +311,6 @@ public int hashCode() {
316
311
317
312
@ Override
318
313
public String toString () {
319
- return listToString (this );
314
+ return ImmutableCollectionUtils . listToString (this );
320
315
}
321
316
}
0 commit comments