Added total().

git-svn-id: https://samskivert.googlecode.com/svn/trunk@923 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-11-12 05:23:41 +00:00
parent 6d1e0d975a
commit 39856ea7fc
@@ -1,5 +1,5 @@
//
// $Id: IntListUtil.java,v 1.2 2002/03/14 03:48:44 mdb Exp $
// $Id: IntListUtil.java,v 1.3 2002/11/12 05:23:41 mdb Exp $
package com.samskivert.util;
@@ -287,6 +287,18 @@ public class IntListUtil
return nlist;
}
/**
* Returns the total of all of the values in the list.
*/
public static int total (int[] list)
{
int total = 0, lsize = list.length;
for (int ii = 0; ii < lsize; ii++) {
total += list[ii];
}
return total;
}
/**
* Creates a new list that will accomodate the specified index and
* copies the contents of the old list to the first.