Emailid
Password
         
  
    Forgot password

New user Sign Up
 

The Jakarta Commons Collections component

       Current Rating:  0%                                                     Total Members Rated:  0
                                                                     Send To Friend

  

The Jakarta Commons Collections component

 

Introduction

 

Various special executions are well classified and understood. At the same time they are not part of the core Collections Framework.  A number of these implementations might be included with the happening together utilities library (JSR 166) discussed in more detail afterwards.

 

Implementation

 

The Commons Collections component provides two List implementations and eight Map implementations and is designed to work with J2SE 1.2. New base structures are also available and are motivating. The Jakarta Commons Collections component is one example of a set of specialized implementations.

 

 

Custom implementations in groups

 

1. Fast Array List, Fast Hash Map, and Fast Tree Map: The simplest to explain are the Fast Array List, Fast Hash Map, and Fast Tree Map implementations. These extend the standard Array List, Hash Map, and Tree Map implementations that offer safe simultaneous read-write access from multiple threads. However, safety comes at the cost of slower write operations. While the read operations aren't synchronized, the write operations are performed on a data clone before the existing structure is replaced. The Bag acts like a Set but permits duplicates.

 

2. Hash Bag and Tree Bag: Two more implementations are available here: HashBag and Tree Bag; the latter is sorted.

 

3. Priority Queue: Another new interface is Priority Queue. It supports comparable items and the use of a Comparator, so items can be maintained in a Binary Heap based on priority and subsequently removed from the heap based on that priority.

 

4. The remaining implementations are a set of specialized Map implementations. They offer special-purpose, key-value pair lookup maps.

 

5. Bean Map:  Bean Map uses reflection to provide key-value pairs based on JavaBean properties; the key is the property name, and the value is its value.

 

6. Extended Properties provides an extension to the java. util. Properties class that concatenates multiple values for a single property, instead of overwriting it.

 

7. LRU Map is a Map that lets you maintain a maximum capacity and uses a least-used (accessed) algorithm to determine which node to remove when full. This capability is already accessible from the standard.

 

8.  Linked Hash Map class, but is only available with J2SE 1.4.

 

9. Soft Ref Hash Map works like Weak Hash Map but uses Soft Reference instead of Weak Reference for its keys.

 

10. Multi Hash Map provides a multi map, where keys can have multiple associated values. Fetching the value for a key returns a Collection instead of the specific value for the key.

 

11. Double Ordered Map is the most interesting of the bunch. It provides a Map that supports fast lookup by value and by key. It has one requirement though: both keys and values must be unique. You can do this with two Tree Map objects, but Double Ordered Map only saves each key-value pair once.

 

 

Conclusion

 

In another way other classes and interfaces serve mostly supporting roles, but some specialized behavior is available. Besides utility methods to work with sets like is Sub Collection and union, the framework includes additional Comparators and Iterators. The Comparators are used mostly for chaining or changing another Comparator's behavior. For instance, while java.util.Collections.reverseOrder() lets you reverse the natural order of elements, the ReverseComparator class lets you reverse the order from any Comparator. The Iterators support the process of passing each Collection element to a method before getting the element back. This is a shared behavior of JGL and STL too. And it is useful in many ways.


                           Rate This Article:   

Author is Offline
  Author: Hilda Wasah
       


Comments Posted
Label
Subject Author Status Date

 

Post Comment

Related Articles
N-Tier in ASP.NET or other .NET apps
The importance of Keywords
The benefits of Cascading Style Sheets (CSS)
For the proper display of your site
Do you want to get on the top?



Home | About Us | Site Map | Privacy Policy | Submit Links