garydgregory commented on code in PR #1270:
URL: https://github.com/apache/commons-lang/pull/1270#discussion_r1741984262


##########
src/main/java/org/apache/commons/lang3/SortedArrayUtils.java:
##########
@@ -0,0 +1,90 @@
+package org.apache.commons.lang3;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.function.Function;
+
+
+/**
+ * Operations on sorted arrays.
+ *
+ * @author Zbynek Vyskovsky

Review Comment:
   We do not use `@author` tags, please remove it. Contributors are usually 
credited in `changes.xml` after a PR is merged.
   



##########
src/main/java/org/apache/commons/lang3/SortedListUtils.java:
##########
@@ -0,0 +1,89 @@
+package org.apache.commons.lang3;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.function.Function;
+
+
+/**
+ * Operations on sorted {@link List}.
+ *
+ * @author Zbynek Vyskovsky
+ */
+public class SortedListUtils {
+    /**
+     * Finds element in sorted list.
+     *
+     * @param a
+     *      list sorted by key field
+     * @param key
+     *      key to search for
+     * @param keyExtractor
+     *      function to extract key from element
+     * @param c
+     *      comparator for keys
+     *
+     * @return
+     *      index of the search key, if it is contained in the array within 
the specified range; otherwise, (-(insertion
+     *      point) - 1). The insertion point is defined as the point at which 
the key would be inserted into the array:
+     *      the index of the first element in the range greater than the key, 
or toIndex if all elements in the range
+     *      are less than the specified key. Note that this guarantees that 
the return value will be >= 0 if and only if
+     *      the key is found.
+     *
+     * @param <T>
+     *     type of array element
+     * @param <K>
+     *     type of key
+     */
+    public static <K, T> int binarySearch(List<T> a, K key,
+                                          Function<T, K> keyExtractor, 
Comparator<? super K> c) {
+        return binarySearch(a, 0, a.size(), key, keyExtractor, c);
+    }
+
+    /**
+     * Finds element in sorted list, within range fromIndex - toIndex 
(inclusive - exclusive).
+     *
+     * @param a
+     *      list sorted by key field
+     * @param fromIndex
+     *      start index
+     * @param toIndex
+     *      end index (exclusive)
+     * @param key
+     *      key to search for
+     * @param keyExtractor
+     *      function to extract key from element
+     * @param c
+     *      comparator for keys
+     *
+     * @return
+     *      index of the search key, if it is contained in the array within 
the specified range; otherwise, (-(insertion
+     *      point) - 1). The insertion point is defined as the point at which 
the key would be inserted into the array:
+     *      the index of the first element in the range greater than the key, 
or toIndex if all elements in the range
+     *      are less than the specified key. Note that this guarantees that 
the return value will be >= 0 if and only if
+     *      the key is found.
+     *
+     * @param <T>
+     *     type of array element
+     * @param <K>
+     *     type of key
+     */
+    public static <T, K> int binarySearch(List<T> a, int fromIndex, int 
toIndex, K key,

Review Comment:
   This code looks like a copy-paste with small edits based on Java's 
`Arrays.binarySearch0()` method, this might violate Oracle's license. IOW, you 
can't copy the JDK's code. If we are serious about adding something like this, 
it has to be different or we'll need to check with our legal mailing list. 
Let's see what others think.



##########
src/main/java/org/apache/commons/lang3/SortedArrayUtils.java:
##########
@@ -0,0 +1,90 @@
+package org.apache.commons.lang3;

Review Comment:
   All new files MUST carry the Apache license header:
   ```
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    *
    *      http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
   ```
   



##########
src/main/java/org/apache/commons/lang3/SortedListUtils.java:
##########
@@ -0,0 +1,89 @@
+package org.apache.commons.lang3;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.function.Function;
+
+
+/**
+ * Operations on sorted {@link List}.
+ *
+ * @author Zbynek Vyskovsky
+ */
+public class SortedListUtils {

Review Comment:
   Collection utilities do not belong in Commons Lang IMO. This would be for 
Commons Collections unless this functionality is already there.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to