Added total().
git-svn-id: https://samskivert.googlecode.com/svn/trunk@923 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user