Type-Specific Collections Library

本项目在 Java Collections集合工具 中的评分:   7

Why another collections library?

The Java libraries included basic Hashtable, Stack and Vector collections classes from the beginning. With Java 2, the addition of the Collections Library increased the variety of collections dramatically, as well as offering improved performance in some areas. Even with the improved support in Java 2, though, there's still reason to use alternatives to the standard library classes for high-performance applications.

Performance and clarity benefits

The biggest performance problem with the standard classes is that they only work with objects, not with primitive types. To build a collection of primitive values, such as ints, you need to create an object wrapper for each value added to the collection. This causes considerable overhead both when initially adding values and when accessing the values later, since you have to first cast the object reference to the appropriate type and then retrieve the actual value.

Even with collections of objects, the library classes are not optimized for performance. Timing measurements listed under the Timings topic show a better than 20 percent increase in performance using the classes from this library in a test with Integer objects and generic collections. For primitive int values in a type-specific collection the performance increase is much greater, to almost 4 times that for the Integers in a standard IntArray.

In addition, these library classes allow more robust code because no casting of values is required. Casting bypasses the type checking done by the compiler and defers the checking to runtime, when mistakes are generally a lot more painful to catch. Using type-specific collections restores the type checking responsibility to the compiler and assures that errors are caught before they're turned into executing code. Getting rid of the casts also makes your code cleaner and easier to understand.



其他Java Java Collections集合工具 开源项目资源:

本网站对列举的开源项目、软件、源码、类库所评定的分值(PR, Progject Rank),是根据该项目的规模、复杂度、采用人数、开发人数、活跃度、说明文档、演示网站等诸多因素综合所给出主观评价,仅供你参考之用。
List of Companies, Suppliers, Distributors, Importers & Exporters
收藏本网站 | 联系我们 | 英文图书网 | 十万个为什么 | Sitemap生成器 | 国际商贸
Copyright © 2007 - 2012 Why and How