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

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
主站蜘蛛池模板: 毕节市| 富民县| 襄汾县| 长兴县| 黑龙江省| 方正县| 蕉岭县| 池州市| 喜德县| 望江县| 会理县| 格尔木市| 崇义县| 定西市| 尚义县| 德兴市| 兴义市| 宕昌县| 特克斯县| 长武县| 土默特右旗| 叙永县| 府谷县| 永平县| 静宁县| 三门县| 宁化县| 盱眙县| 政和县| 马边| 札达县| 上思县| 红原县| 泌阳县| 武鸣县| 万年县| 油尖旺区| 武汉市| 黑山县| 隆子县| 阳高县|