Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Accumulate 1.0

Thread Tools

Accumulate 1.0

Roedy Green
Posts: n/a
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.


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]
+ ":"
+ 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

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See for The Java Glossary.
Reply With Quote

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 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 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