Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > accumulate() usage

Reply
Thread Tools

accumulate() usage

 
 
Allerdyce.John@gmail.com
Guest
Posts: n/a
 
      02-02-2006
Hi,

I have a function with add elements of a STL list from 'start' to
'end'.
In the debugger, the size of the list is 2 and start is 0 and end is 1.
But it never goes itside 'do_add' and it just return 0. I expect it
just 'sum' the FIRST element (since start is 0 and end is 1).

Can you please tell me why is that?

_myList is a type of vector<int>
float getTotal(int start,int end) {
vector<int>::iterator beginItr = _myList.begin() + start;
vector<int>::iterator endItr = _myList.begin() + end;


return accumulate (beginItr, endItr, 0.0, do_add<int, float>());

}

 
Reply With Quote
 
 
 
 
Neelesh Bodas
Guest
Posts: n/a
 
      02-02-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> But it never goes itside 'do_add' and it just return 0. I expect it
> just 'sum' the FIRST element (since start is 0 and end is 1).
>
> Can you please tell me why is that?
>
> _myList is a type of vector<int>
> float getTotal(int start,int end) {
> vector<int>::iterator beginItr = _myList.begin() + start;
> vector<int>::iterator endItr = _myList.begin() + end;
> return accumulate (beginItr, endItr, 0.0, do_add<int, float>());


This code works fine when I tried it (After adding necessary minimal
definitions and other stuff). Could you please give the complete code
which demonstrates the problem?

 
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
What is the difference between Memory Usage and Heap Usage in my JVMMetrics ? Krist Java 8 02-10-2010 12:44 AM
retrieving CPU Usage and Memory Usage information in JAVA hvt Java 0 03-13-2007 01:09 PM
retrieving CPU Usage and Memory Usage information in JAVA hvt Java 0 03-13-2007 01:07 PM
Webchecker Usage - a problem with local usage Colin J. Williams Python 1 02-26-2004 12:28 AM
Need help on memory usage VS PF usage metfan Java 2 10-21-2003 01:58 PM



Advertisments