Skip to content

Commit b14571d

Browse files
committed
Update Collections.
1 parent 5cbb171 commit b14571d

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,15 +954,17 @@ public static <E> List<E> emptyListOf(Class<E> elementType) { ... }
954954
```
955955

956956
```java
957-
public static <K, V> Map<K, V> mapOf(Map.Entry<K, V>... entries) { ... }
957+
public static <K, V> SequencedMap<K, V> mapOf(Map.Entry<K, V>... entries) { ... }
958+
958959
public static <K, V> Map<K, V> immutableMapOf(Map.Entry<K, V>... entries) { ... }
959960
public static <K, V> Map<K, V> emptyMapOf(Class<K> keyType, Class<V> valueType) { ... }
960961

961962
public static <K extends Comparable<? super K>, V> SortedMap<K, V> sortedMapOf(Map.Entry<K, V>... entries) { ... }
962963
```
963964

964965
```java
965-
public static <E> Set<E> setOf(E... elements) { ... }
966+
public static <E> SequencedSet<E> setOf(E... elements) { ... }
967+
966968
public static <E> Set<E> immutableSetOf(E... elements) { ... }
967969
public static <E> Set<E> emptySetOf(Class<E> elementType) { ... }
968970

kilo-client/src/main/java/org/httprpc/kilo/util/Collections.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import java.util.LinkedHashSet;
2121
import java.util.List;
2222
import java.util.Map;
23+
import java.util.SequencedMap;
24+
import java.util.SequencedSet;
2325
import java.util.Set;
2426
import java.util.SortedMap;
2527
import java.util.SortedSet;
@@ -174,7 +176,7 @@ public static <E> List<E> emptyListOf(Class<E> elementType) {
174176
* A map containing the provided entries in the order given.
175177
*/
176178
@SafeVarargs
177-
public static <K, V> Map<K, V> mapOf(Map.Entry<K, V>... entries) {
179+
public static <K, V> SequencedMap<K, V> mapOf(Map.Entry<K, V>... entries) {
178180
var map = new LinkedHashMap<K, V>(entries.length);
179181

180182
for (var entry : entries) {
@@ -201,7 +203,7 @@ public static <K, V> Map<K, V> mapOf(Map.Entry<K, V>... entries) {
201203
* @return
202204
* A map containing the provided entries in the order given.
203205
*/
204-
public static <K, V> Map<K, V> mapOf(Iterable<? extends Map.Entry<? extends K, ? extends V>> entries) {
206+
public static <K, V> SequencedMap<K, V> mapOf(Iterable<? extends Map.Entry<? extends K, ? extends V>> entries) {
205207
if (entries == null) {
206208
throw new IllegalArgumentException();
207209
}
@@ -399,7 +401,7 @@ public static <K, V> Map.Entry<K, V> entry(K key, V value) {
399401
* A set containing the provided elements in the order given.
400402
*/
401403
@SafeVarargs
402-
public static <E> Set<E> setOf(E... elements) {
404+
public static <E> SequencedSet<E> setOf(E... elements) {
403405
var set = new LinkedHashSet<E>(elements.length);
404406

405407
java.util.Collections.addAll(set, elements);
@@ -419,7 +421,7 @@ public static <E> Set<E> setOf(E... elements) {
419421
* @return
420422
* A set containing the provided elements in the order given.
421423
*/
422-
public static <E> Set<E> setOf(Iterable<? extends E> elements) {
424+
public static <E> SequencedSet<E> setOf(Iterable<? extends E> elements) {
423425
if (elements == null) {
424426
throw new IllegalArgumentException();
425427
}

0 commit comments

Comments
 (0)