You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Duncan Jones (JIRA)" <ji...@apache.org> on 2015/03/26 16:53:54 UTC

[jira] [Comment Edited] (LANG-1074) Add a method to ArrayUtils for removing all occurrences of a given element

    [ https://issues.apache.org/jira/browse/LANG-1074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14382087#comment-14382087 ] 

Duncan Jones edited comment on LANG-1074 at 3/26/15 3:53 PM:
-------------------------------------------------------------

Sorry, still doesn't work for me.

If you are using Eclipse, please do the following to create a valid patch:

# Right-click on project > Team > Create Patch...
# Select "In file system" and choose somewhere to store the patch file
# On the Advanced options, ensure Patch Root = Project. Selected patch options should be:
 - "Recurse into sub-folders"
 - "Process deleted resources"
 - "Process new resources"

See also https://commons.apache.org/patches.html (although this essentially says the same thing).

I think in your first patch, you perhaps used the workspace as the patch root.


was (Author: dmjones500):
Sorry, still doesn't work for me.

If you are using Eclipse, please do the following to create a valid patch:

# Right-click on project > Team > Create Patch...
# Select "In file system" and choose somewhere to store the patch file
# On the Advanced options, ensure Patch Root = Project. Selected patch options should be:
 - "Recurse into sub-folders"
 - "Process deleted resources"
 - "Process new resources"

See also https://commons.apache.org/patches.html (although this essentially says the same thing).

> Add a method to ArrayUtils for removing all occurrences of a given element
> --------------------------------------------------------------------------
>
>                 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: Review Patch
>
>         Attachments: LANG-1074.patch.txt, LANG-1074_20150320.patch
>
>
> Could we add the method: removeElementAll to remove all the occurrences of the specified element from the specified (boolean/char/byte/short/int/long/float/double/Object) array:
> {code:title=org.apache.commons.lang3.ArrayUtils.java|borderStyle=solid}
>     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 - index];
>         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}
> or maybe better:
> {code:title=org.apache.commons.lang3.ArrayUtils.java|borderStyle=solid}
>    public static <T> T[] removeElement(final T[] a, final Object element, boolean removeAll) {
>         int index = indexOf(a, element);
>         if (index == INDEX_NOT_FOUND) {
>             return clone(a);
>         } else if (!removeAll || index >= a.length - 1) {
>             return remove(a, index);
>         } else {
>             int[] indices = new int[a.length - index];
>             int count = 0;
>             indices[count++] = index++;
>             
>             for (int len = a.length; index < len; index++) {
>                 if ((a[index] == null) ? element == null : (element == null ? false : a[index].equals(element))) {
>                     indices[count++] = index;
>                 }
>             }
>             return (T[]) removeAll((Object) a, Arrays.copyOfRange(indices, 0, count));
>         }
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)