add method retainAll
This commit is contained in:
@@ -261,6 +261,26 @@ public final class IntList implements Serializable, Cloneable {
|
||||
index = insertPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retains all elements contained in the specified list.
|
||||
*
|
||||
* @param retain
|
||||
* the elements to retain
|
||||
*/
|
||||
public void retainAll(final IntList retain) {
|
||||
final int size = index;
|
||||
int insertPosition = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
final int current = data[i];
|
||||
if (retain.indexOf(current) >= 0) {
|
||||
// keep current element
|
||||
data[insertPosition] = current;
|
||||
insertPosition++;
|
||||
}
|
||||
}
|
||||
index = insertPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all values in the list by applying {@code operator}.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user