Skip to content

Commit 9965918

Browse files
Abduqodiri Qurbonzodaqurbonzoda
authored andcommitted
Introduce separate methods for creating empty maps and sets
1 parent dcb7755 commit 9965918

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

core/commonMain/src/extensions.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,11 @@ fun <E> persistentSetOf(): PersistentSet<E> = PersistentOrderedSet.emptyOf<E>()
448448
*/
449449
fun <E> persistentHashSetOf(vararg elements: E): PersistentSet<E> = PersistentHashSet.emptyOf<E>().addAll(elements.asList())
450450

451+
/**
452+
* Returns an empty persistent set.
453+
*/
454+
fun <E> persistentHashSetOf(): PersistentSet<E> = PersistentHashSet.emptyOf()
455+
451456

452457
/**
453458
* Returns a new persistent map with the specified contents, given as a list of pairs
@@ -459,6 +464,12 @@ fun <E> persistentHashSetOf(vararg elements: E): PersistentSet<E> = PersistentHa
459464
*/
460465
fun <K, V> persistentMapOf(vararg pairs: Pair<K, V>): PersistentMap<K, V> = PersistentOrderedMap.emptyOf<K,V>().mutate { it += pairs }
461466

467+
/**
468+
* Returns an empty persistent map.
469+
*/
470+
fun <K, V> persistentMapOf(): PersistentMap<K, V> = PersistentOrderedMap.emptyOf()
471+
472+
462473
/**
463474
* Returns a new persistent map with the specified contents, given as a list of pairs
464475
* where the first component is the key and the second is the value.
@@ -469,6 +480,11 @@ fun <K, V> persistentMapOf(vararg pairs: Pair<K, V>): PersistentMap<K, V> = Pers
469480
*/
470481
fun <K, V> persistentHashMapOf(vararg pairs: Pair<K, V>): PersistentMap<K, V> = PersistentHashMap.emptyOf<K,V>().mutate { it += pairs }
471482

483+
/**
484+
* Returns an empty persistent map.
485+
*/
486+
fun <K, V> persistentHashMapOf(): PersistentMap<K, V> = PersistentHashMap.emptyOf()
487+
472488

473489
/**
474490
* Returns a new persistent list of the specified elements.

0 commit comments

Comments
 (0)