From 18ae646e572a27c4d28ab256cbd6f5e5f8555511 Mon Sep 17 00:00:00 2001 From: "ray.j.greenwell" Date: Tue, 6 Jul 2010 17:19:22 +0000 Subject: [PATCH] Deprecate size(), add getSize(). git-svn-id: https://samskivert.googlecode.com/svn/trunk@2792 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/ListUtil.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/java/com/samskivert/util/ListUtil.java b/src/java/com/samskivert/util/ListUtil.java index 73c348cc..36b6b9e2 100644 --- a/src/java/com/samskivert/util/ListUtil.java +++ b/src/java/com/samskivert/util/ListUtil.java @@ -439,9 +439,10 @@ public class ListUtil } /** - * Returns the number of elements in the supplied list. + * Returns the number of elements prior to the first null in the supplied list. + * @deprecated This is incompatible with things like clearRef(), which leave a null space. */ - public static int size (Object[] list) + @Deprecated public static int size (Object[] list) { if (list == null) { return 0; @@ -455,6 +456,20 @@ public class ListUtil return llength; } + /** + * Returns the number of non-null elements in the supplied list. + */ + public static int getSize (Object[] list) + { + int size = 0; + for (int ii = 0, nn = (list == null) ? 0 : list.length; ii < nn; ii++) { + if (list[ii] != null) { + size++; + } + } + return size; + } + /** * Creates a new list that will accomodate the specified index and * copies the contents of the old list to the first.