官术网_书友最值得收藏!

Commons Collections

The Java Collections API is very powerful and it defines a good set of abstractions for data structures in Java. The Commons Collections use these abstractions and extend the standard Collections API with new implementations as well as new collections. To include the library, use this snippet:

<dependency> 
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>

Some useful collections from this library are:

  • Bag: This is an interface for sets that can hold the same element multiple times
  • BidiMap: This stands for Bi-directional map. It can map from keys to values and from values to keys

It has some overlap with collections from Google Guava, explained in the next session, but has some additional collections that aren't implemented there. For example,

  • LRUMap: This is used for implementing caches
  • PatriciaTrie: This is used for fast string prefix lookups
主站蜘蛛池模板: 开原市| 呼图壁县| 安宁市| 香港 | 故城县| 肃南| 海丰县| 太和县| 鄯善县| 焦作市| 大丰市| 萨迦县| 西昌市| 林口县| 张家川| 安吉县| 镇巴县| 松原市| 桂平市| 孙吴县| 开江县| 常德市| 南昌县| 青河县| 汉源县| 咸宁市| 济宁市| 京山县| 安国市| 平邑县| 胶州市| 宜良县| 偃师市| 阿拉善右旗| 忻州市| 天台县| 思南县| 定襄县| 固始县| 兖州市| 蒙阴县|