Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Accumulate 1.0

Reply
Thread Tools

Accumulate 1.0

 
 
Roedy Green
Guest
Posts: n/a
 
      07-17-2004
Accumulate Version 1.0

Accumulate amounts by category

Class library used to accumulate values by category.
It might be useful for example in a billing program
to accumulate hours by various categories.

It could be used to count how many times various words
occurred in a document.

All you need to is say:

buckets.accumulate( "somecategory", someamount );

And Accumulate looks after creating the buckets to
accumulate new categories for you.

e.g.

Accumulate buckets = new Accumulate( 20 );
buckets.accumulate( "ugli fruit", 3 );
buckets.accumulate( "peaches", 10 );
buckets.accumulate( "strawberries", 15 );
buckets.accumulate( "peaches", 14 );
String[] categories = buckets.categories();

// prints:
// peaches:24
// strawberries:15
// ugli fruit:3
for ( int i=0; i<categories.length; i++ )
{
System.out.println( categories[i]
+ ":"
+ buckets.total( categories[i] ));
}

Freeware copyright 2004 Canadian Mind Products.
May be used freely for any purpose but military.
All Java source code is included.
download from http://mindprod.com/products.html#ACCUMULATE


--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Boost algorithm ll::accumulate question Henrique A. Menarin C++ 7 01-29-2007 09:37 PM
How to use Boost bind library with STL accumulate algorithm yinglcs@gmail.com C++ 1 02-15-2006 11:03 AM
Using accumulate algorithm with a set of pairs cesco C++ 5 02-13-2006 03:12 PM
accumulate() usage Allerdyce.John@gmail.com C++ 1 02-02-2006 06:30 AM
64 bit add and accumulate with MMX Brian K. Michalk Perl 6 09-20-2003 08:43 PM



Advertisments