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

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
主站蜘蛛池模板: 怀来县| 丹江口市| 仲巴县| 凤翔县| 黎城县| 南岸区| 和静县| 翼城县| 乐平市| 南澳县| 德昌县| 静乐县| 福建省| 沂水县| 隆子县| 丰台区| 翁牛特旗| 仙游县| 鸡东县| 当雄县| 报价| 山丹县| 霍城县| 六枝特区| 仁布县| 荔浦县| 松江区| 通渭县| 平邑县| 额敏县| 遂川县| 华池县| 依兰县| 南皮县| 肇东市| 萨嘎县| 温州市| 天柱县| 台州市| 正阳县| 布尔津县|