From 8d9ccdb08e827562293814d9ef24fe0c3f8383cd Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Wed, 6 Mar 2024 15:15:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=84=8F=E4=B9=89=E4=B8=8D?= =?UTF-8?q?=E5=A4=A7=E7=9A=84=E9=9B=86=E5=90=88=E5=B7=A5=E5=85=B7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plusone/commons/collection/ListTools.java | 15 ----- .../plusone/commons/collection/MapTools.java | 17 ----- .../commons/collection/TableTools.java | 17 ----- .../plusone/commons/util/ArrayTools.java | 64 ------------------- 4 files changed, 113 deletions(-) delete mode 100644 src/main/java/xyz/zhouxy/plusone/commons/collection/ListTools.java delete mode 100644 src/main/java/xyz/zhouxy/plusone/commons/collection/MapTools.java delete mode 100644 src/main/java/xyz/zhouxy/plusone/commons/collection/TableTools.java diff --git a/src/main/java/xyz/zhouxy/plusone/commons/collection/ListTools.java b/src/main/java/xyz/zhouxy/plusone/commons/collection/ListTools.java deleted file mode 100644 index 1ff2972..0000000 --- a/src/main/java/xyz/zhouxy/plusone/commons/collection/ListTools.java +++ /dev/null @@ -1,15 +0,0 @@ -package xyz.zhouxy.plusone.commons.collection; - -import java.util.List; -import java.util.function.Function; - -public class ListTools { - - public static void transformValue(List list, int index, Function func) { - list.set(index, func.apply(list.get(index))); - } - - private ListTools() { - throw new IllegalStateException("Utility class"); - } -} diff --git a/src/main/java/xyz/zhouxy/plusone/commons/collection/MapTools.java b/src/main/java/xyz/zhouxy/plusone/commons/collection/MapTools.java deleted file mode 100644 index f96dab8..0000000 --- a/src/main/java/xyz/zhouxy/plusone/commons/collection/MapTools.java +++ /dev/null @@ -1,17 +0,0 @@ -package xyz.zhouxy.plusone.commons.collection; - -import java.util.Map; -import java.util.function.Function; - -public class MapTools { - - public static void transformValue(Map map, K key, Function func) { - if (map.containsKey(key)) { - map.put(key, func.apply(map.get(key))); - } - } - - private MapTools() { - throw new IllegalStateException("Utility class"); - } -} diff --git a/src/main/java/xyz/zhouxy/plusone/commons/collection/TableTools.java b/src/main/java/xyz/zhouxy/plusone/commons/collection/TableTools.java deleted file mode 100644 index 0070b05..0000000 --- a/src/main/java/xyz/zhouxy/plusone/commons/collection/TableTools.java +++ /dev/null @@ -1,17 +0,0 @@ -package xyz.zhouxy.plusone.commons.collection; - -import com.google.common.collect.Table; - -public class TableTools { - - public static Table synchronizedTable(Table t) { - if (t instanceof SynchronizedTable) { - return t; - } - return SynchronizedTable.of(t); - } - - private TableTools() { - throw new IllegalStateException("Utility class"); - } -} diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/ArrayTools.java b/src/main/java/xyz/zhouxy/plusone/commons/util/ArrayTools.java index c5d7bd3..2fd3849 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/ArrayTools.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/ArrayTools.java @@ -17,23 +17,14 @@ package xyz.zhouxy.plusone.commons.util; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.function.Function; import javax.annotation.Nullable; import com.google.common.annotations.Beta; -import xyz.zhouxy.plusone.commons.collection.CollectionTools; -import xyz.zhouxy.plusone.commons.collection.SafeConcurrentHashMap; - @Beta public class ArrayTools { @@ -186,61 +177,6 @@ public class ArrayTools { return result; } - // array -> map - - public static HashMap toHashMap( - V[] c, - Function keyGenerator, - int initialCapacity) { - HashMap map = new HashMap<>(initialCapacity); - fillIntoEmptyMap(map, c, keyGenerator); - return map; - } - - public static HashMap toHashMap( - V[] c, - Function keyGenerator) { - return toHashMap(c, keyGenerator, c.length); - } - - public static SafeConcurrentHashMap toConcurrentHashMap( - V[] c, - Function keyGenerator, - int initialCapacity) { - SafeConcurrentHashMap map = new SafeConcurrentHashMap<>(initialCapacity); - fillIntoEmptyMap(map, c, keyGenerator); - return map; - } - - public static SafeConcurrentHashMap toConcurrentHashMap( - V[] c, - Function keyGenerator) { - return toConcurrentHashMap(c, keyGenerator, c.length); - } - - public static , V> TreeMap toTreeMap( - V[] c, - Function keyGenerator) { - TreeMap map = new TreeMap<>(); - fillIntoEmptyMap(map, c, keyGenerator); - return map; - } - - public static TreeMap toTreeMap( - V[] c, - Function keyGenerator, - Comparator keyComparator) { - TreeMap map = new TreeMap<>(keyComparator); - fillIntoEmptyMap(map, c, keyGenerator); - return map; - } - - public static void fillIntoEmptyMap( - Map map, V[] c, - Function keyGenerator) { - CollectionTools.fillIntoEmptyMap(map, Arrays.asList(c), keyGenerator); - } - private ArrayTools() { throw new IllegalStateException("Utility class"); }