os_min_element, os_min_element_value


Finds the minimum item in a container.

Helper algorithms for min_element() . The first version sets t to point to the minimum element of container c , or zero if c is empty. If container c is not empty, the second version sets t to the minimum element of c and returns true ; otherwise, the algorithm returns false .

Library

Helper<ToolKit>

Declaration

#include <ospace/helper/helpalgo.h>

template< class Container, class T >
void os_min_element( const Container& c, T*& t )

template< class Container, class T >
bool os_min_element_value( const Container& c, T& t )
Example <ospace/helper/examples/ominelm0.cpp>
#include <iostream>
#include <vector>
#include <ospace/helper.h>

int numbers[ 6 ] = { -10, 15, -100, 36, -242, 42 };

void
main()
  {
  vector< int > v( numbers, numbers + 6 );
  int* ptr;

  os_min_element( v, ptr );

  if ( ptr )
    cout << "minimum = " << *ptr << "\n";;
  int value;

  bool result = os_min_element_value( v, value );

  if ( result )
    cout << "minimum = " << value << "\n";
  }

minimum = -242
minimum = -242

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.