Java 1.6 provides the better bi-directional collection access on collections framework.
The following new interfaces are added in this version:
i) Deque - It is a double ended queue, supporting element insertion and removal at both ends. It extends the Queue interface.
ii) BlockingDeque - Its inheriting the feature of deque and performs the operations that wait for deque to become non-empty and wait for space to become available in the deque when storing elements.
iii) NavigableSet - It may be accessed and traversed in either ascending and descending order.
iv) NavigableMap - It may be accessed and traversed in either ascending and descending key order.
V) ConcurrentNavigableMap - Its similar to NavigableMap and this interface is part of java.util.concurrent.
The following classes have been added:
i) ArrayDeque
ii) ConcurrentSkiplistSet
iii) ConcurrentSkipListMap
iv) LinkedBlockingQueue
v) AbstractMap.SimpleEntry
vi) AbstratMap.SimpleImmutableEntry
Other than this Two new methods were added to the Collection Utility classes:
1. newSetFromMap(Map) -- Create a Set implementaion from Map. There is no IdentitiHashSet class but instead, just use
Set<Object> identityHashSet = Collections.newSetFromMap(new IdentityHashMap<object, Boolean>());
2. asLifoQueue(Deque) - returns a view of a Deque as a Last-in-first-out (Lifo) Queue
The Arrays utility class now has methods copyOf and copyOfRange that can efficiently resize, truncate, or copy subarrays for arrays of all types.
Before:
int[] newArray = new int[newLength];
System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
After:
int[] newArray = Arrays.copyOf(a, newLength);
No comments:
Post a Comment