From 9f0e3fc3c827edef4092228d592473e94414535b Mon Sep 17 00:00:00 2001 From: shaper Date: Fri, 6 Sep 2002 02:09:05 +0000 Subject: [PATCH] Added size(). git-svn-id: https://samskivert.googlecode.com/svn/trunk@826 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/util/ListUtil.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/ListUtil.java b/projects/samskivert/src/java/com/samskivert/util/ListUtil.java index bca08728..3b2a327f 100644 --- a/projects/samskivert/src/java/com/samskivert/util/ListUtil.java +++ b/projects/samskivert/src/java/com/samskivert/util/ListUtil.java @@ -1,5 +1,5 @@ // -// $Id: ListUtil.java,v 1.7 2002/04/13 01:39:17 mdb Exp $ +// $Id: ListUtil.java,v 1.8 2002/09/06 02:09:05 shaper Exp $ package com.samskivert.util; @@ -420,6 +420,20 @@ public class ListUtil return elem; } + /** + * Returns the number of elements in the supplied list. + */ + public static int size (Object[] list) + { + int llength = list.length; + for (int ii = 0; ii < llength; ii++) { + if (list[ii] == null) { + return ii; + } + } + return llength; + } + /** * Creates a new list that will accomodate the specified index and * copies the contents of the old list to the first.