Thread: min, max_element and accumulate

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    385

    min, max_element and accumulate

    I am trying to find functions in the managed C++ that equals the 3 functions below. Though I have a problem to find these.
    Would be very happy for any idéas.

    max_element can ex: search through a range of elements in a std::vector<int>
    and return the highest value.

    min_element can ex: search through a range of elements in a std::vector<int>
    and return the lowest value.

    accumulate can sum a range of elements in a std::vector<int>
    and return the accumulated sum.



    Code:
    std::max_element( start, end );
    std::min_element( start, end );
    std::accumulate( start, end );

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I am not familiar with managed C++, but can't you just use those standard generic algorithms in managed C++?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    385
    Ok, I dont think that is possible. I think I have to use the System:: to find any members for this.

    I did find this function but it only tells wich of the argument that has the greatest value(wich is 5).
    It is not possible to put like for a vector1.begin(), vector.end() and find wich value in the range that has the greatest value.

    Code:
    int Get = System::Math::Max( 1, 5 );

Popular pages Recent additions subscribe to a feed