Hi,

I have written a few methods in recent months that may fit with [collections]. I'll do a copy/paste of the signatures + javadoc descriptions. Let me know what you think.

(Apologies if any of this functionality already exists in [collections]. I took a quick look but didn't see any duplication.)


1) void removeAllUsingBinarySearch(List list1, List list2)

2) void retainAllUsingBinarySearch(List list1, List list2)

Functionally the same as List.removeAll(Collection) and List.retainAll(Collection), but uses a binary search in order to find the matches (as opposed to the linear search in Sun's default implementation).

(I was working with collections around 50,000 in size, and this made a very significant performance difference.)


3) List splitByMaximum(List items, int maxSize)

Splits a list into sublists.  Note that this method makes use of
java.util.List.subList(int fromIndex, int toIndex), so the result lists are backed by the original -- changes to the result lists affect the original list.

(I was in a situation where I had a large number of operations to perform, but due to memory constraints I had to limit the number of operations per transaction. This did the trick.)


4) Map subMap(Map map, List keys)

Creates a subset of a map, containing only the specified keys.


5) List getMapValues(Map map, List keys)

Using the provided map, gets the values for the specified keys.


cheers,
matt


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to