all,

i am using the commons collections api and am very impressed with it.  i am largely 
using it to iterate over an arbitrary list, so i mostly use the IteratorUtils class.

one method i needed for a project does not seem to be available though, size(), that 
would return the size of an arbitary list.

so i wrote the following:
        public static int size(Object list) throws IllegalArgumentException {
                int i = 0;
                if (list instanceof Collection) {
                        i = ((Collection)list).size();
                } else if (list instanceof Map) {
                        i = ((Map)list).size();
                } else {
                        i = Array.getLength(list);
                }
                return i;

thought it would be nice to include this functionality in an upcoming commons 
collection release.

thanks,
steve

  
Learn more about Paymentech's payment processing services at www.paymentech.com
THIS MESSAGE IS CONFIDENTIAL.  This e-mail message and any attachments are proprietary 
and confidential information intended only for the use of the recipient(s) named 
above.  If you are not the intended recipient, you may not print, distribute, or copy 
this message or any attachments.  If you have received this communication in error, 
please notify the sender by return e-mail and delete this message and any attachments 
from your computer.
~2

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

Reply via email to