[ 
https://issues.apache.org/jira/browse/LANG-1177?focusedWorklogId=334562&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-334562
 ]

ASF GitHub Bot logged work on LANG-1177:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Oct/19 18:45
            Start Date: 26/Oct/19 18:45
    Worklog Time Spent: 10m 
      Work Description: lielfr commented on pull request #471: [LANG-1177] 
Added indexesOf methods and simplified removeAllOccurences
URL: https://github.com/apache/commons-lang/pull/471#discussion_r339311187
 
 

 ##########
 File path: src/main/java/org/apache/commons/lang3/ArrayUtils.java
 ##########
 @@ -8202,20 +8654,8 @@ public static boolean isSorted(final boolean[] array) {
      * @since 3.5
      */
     public static float[] removeAllOccurences(final float[] array, final float 
element) {
-        int index = indexOf(array, element);
-        if (index == INDEX_NOT_FOUND) {
-            return clone(array);
-        }
-
-        final int[] indices = new int[array.length - index];
-        indices[0] = index;
-        int count = 1;
-
-        while ((index = indexOf(array, element, indices[count - 1] + 1)) != 
INDEX_NOT_FOUND) {
-            indices[count++] = index;
-        }
-
-        return removeAll(array, Arrays.copyOf(indices, count));
+        BitSet foundBits = indexesOf(array, element);
 
 Review comment:
   Done
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 334562)
    Time Spent: 2h 10m  (was: 2h)

> Improve indexOf performance when called multiple times
> ------------------------------------------------------
>
>                 Key: LANG-1177
>                 URL: https://issues.apache.org/jira/browse/LANG-1177
>             Project: Commons Lang
>          Issue Type: Improvement
>            Reporter: Sebb
>            Priority: Major
>          Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> The indexOf methods search for a single entry in an array.
> This works fine when only the first matching entry is needed, however it is 
> not so efficient when all matches are needed (because of the setup/teardown 
> overheads).
> It might be useful to introduce an indexesOf method that returns a BitSet 
> containing all the matches.
> This can then be used in the removeAllOccurrences methods.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to