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

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
主站蜘蛛池模板: 交口县| 朔州市| 江门市| 无锡市| 皮山县| 绿春县| 镇雄县| 淮阳县| 达拉特旗| 泽州县| 富源县| 靖江市| 修文县| 琼中| 甘德县| 威海市| 广宗县| 闵行区| 垦利县| 绥德县| 南通市| 沂水县| 邹城市| 南江县| 清水河县| 岳池县| 桑日县| 青神县| 新源县| 双鸭山市| 安吉县| 克山县| 铜梁县| 峨眉山市| 晋宁县| 万州区| 莱州市| 六安市| 铜川市| 霍山县| 温泉县|