You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2023/01/28 23:08:18 UTC

[groovy] 01/02: GROOVY-7319: Add primitive array min() and max()

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 916a1c5f602f54b634787db7f6e2315a5cf7ebb2
Author: Yu Kobayashi <yu...@accelart.jp>
AuthorDate: Tue Feb 24 09:57:06 2015 +0900

    GROOVY-7319: Add primitive array min() and max()
---
 .../groovy/util/function/DoubleComparator.java     | 34 ++++++++++++++++++++++
 .../java/groovy/util/function/IntComparator.java   | 34 ++++++++++++++++++++++
 .../java/groovy/util/function/LongComparator.java  | 34 ++++++++++++++++++++++
 src/main/java/groovy/util/function/package.html    | 29 ++++++++++++++++++
 4 files changed, 131 insertions(+)

diff --git a/src/main/java/groovy/util/function/DoubleComparator.java b/src/main/java/groovy/util/function/DoubleComparator.java
new file mode 100644
index 0000000000..052be71742
--- /dev/null
+++ b/src/main/java/groovy/util/function/DoubleComparator.java
@@ -0,0 +1,34 @@
+/*
+ *  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.
+ */
+package groovy.util.function;
+
+/**
+ * A comparator of two double values.
+ */
+@FunctionalInterface
+public interface DoubleComparator {
+    /**
+     * Compares its two arguments for order.
+     *
+     * @param v1 The double value to compare.
+     * @param v2 The double value to compare.
+     * @return If v1 is less than v2, returns negative. If v1 equals to v2, returns zero. If v1 is greater than v2, returns positive.
+     */
+    int compare(double v1, double v2);
+}
diff --git a/src/main/java/groovy/util/function/IntComparator.java b/src/main/java/groovy/util/function/IntComparator.java
new file mode 100644
index 0000000000..c599473a41
--- /dev/null
+++ b/src/main/java/groovy/util/function/IntComparator.java
@@ -0,0 +1,34 @@
+/*
+ *  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.
+ */
+package groovy.util.function;
+
+/**
+ * A comparator of two int values.
+ */
+@FunctionalInterface
+public interface IntComparator {
+    /**
+     * Compares its two arguments for order.
+     *
+     * @param v1 The int value to compare.
+     * @param v2 The int value to compare.
+     * @return If v1 is less than v2, returns negative. If v1 equals to v2, returns zero. If v1 is greater than v2, returns positive.
+     */
+    int compare(int v1, int v2);
+}
diff --git a/src/main/java/groovy/util/function/LongComparator.java b/src/main/java/groovy/util/function/LongComparator.java
new file mode 100644
index 0000000000..225cf472aa
--- /dev/null
+++ b/src/main/java/groovy/util/function/LongComparator.java
@@ -0,0 +1,34 @@
+/*
+ *  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.
+ */
+package groovy.util.function;
+
+/**
+ * A comparator of two long values.
+ */
+@FunctionalInterface
+public interface LongComparator {
+    /**
+     * Compares its two arguments for order.
+     *
+     * @param v1 The long value to compare.
+     * @param v2 The long value to compare.
+     * @return If v1 is less than v2, returns negative. If v1 equals to v2, returns zero. If v1 is greater than v2, returns positive.
+     */
+    int compare(long v1, long v2);
+}
diff --git a/src/main/java/groovy/util/function/package.html b/src/main/java/groovy/util/function/package.html
new file mode 100644
index 0000000000..c2f4f5f3e0
--- /dev/null
+++ b/src/main/java/groovy/util/function/package.html
@@ -0,0 +1,29 @@
+<!--
+
+     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.
+
+-->
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <title>package groovy.util.function.*</title>
+  </head>
+  <body>
+    <p>Classes for functional interfaces.</p>
+  </body>
+</html>