[jbosscache-dev] New collections

Manik Surtani manik at jboss.org
Wed Jul 23 11:47:18 EDT 2008


Guys,

I have created 3 new collection impls in trunk - ImmutableListCopy,  
ImmutableSetCopy and ImmutableMapCopy.  I have also ported the first 2  
to branch 2.2.x (the reason why I didnt port the third is because the  
MapCopy which it replaces can get serialized and I don't want to break  
binary compat).

See the Javadoc of these classes for more details, but in a nutshell  
these are very efficient alternatives to the "immutable and  
defensively copied" idiom.  I.e., if you ever find yourself doing:

	return Collections.unmodifiableList(new ArrayList(internalList))

you should consider ImmutableListCopy instead.  Constructon time is  
about a tenth of the combined time it takes to create an ArrayList and  
then wrap it in an UnmodifiableList.  Also, iteration is very quick  
since the internal array is immutable.  Please keep this in mind when  
working on JBC code.

Cheers,
--
Manik Surtani
Lead, JBoss Cache
manik at jboss.org







More information about the jbosscache-dev mailing list