haiyang li created LANG-1074:
--------------------------------
Summary: Add removeElementAll method in class ArrayUtils
Key: LANG-1074
URL: https://issues.apache.org/jira/browse/LANG-1074
Project: Commons Lang
Issue Type: Improvement
Components: lang.*
Affects Versions: 3.3.2
Reporter: haiyang li
Priority: Minor
Fix For: Discussion
Could we add the method: removeElementAll to remove all occurrences of the
specified element from the specified array:
public static <T> T[] removeElementAll(final T[] array, final Object
element) {
int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
}
int[] indices = new int[array.length];
int count = 0;
indices[count++] = index;
for (;;) {
index = indexOf(array, element, index++);
if (index == INDEX_NOT_FOUND) {
break;
} else {
indices[count++] = index;
}
}
return (T[]) removeAll((Object) array, Arrays.copyOfRange(indices, 0,
count));
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)