简体   繁体   中英

How to allow duplicates with ImmutableJS

I need an Immutable Set that allows duplicate values. That is unordered collection with duplicate values allowed.

What you want is usually called multiset or bag; however, immutable.js does not implement such a collection. Simple workaround is to use immutable Map, mapping individual elements (you would like to store in the set) to their quantities.

Example: multiset {a,a,a,b,b} may be represented as {a: 3, b: 2}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM