/* 
 * File:   vprint.h
 * Author: gpk
 *
 * Created on 25 June 2011, 13:48
 */

#ifndef VECTOR_HELPER_HPP
#define	VECTOR_HELPER_HPP

#include <vector>
#include <ostream>

/**
* A quick-and-dirty way to print a Standard Template Library vector.
*/

template<typename T>
typename std::ostream& operator<<(std::ostream& s, const std::vector<T>& x)
{
    for(typename std::vector<T>::const_iterator i=x.begin(); i!=x.end(); i++) {
        if(i != x.begin())
            s << ", ";
        s << *i;
    }
    return s;
}

/**
* Check if a vector is nondecreasing.
*/

template<typename Y>
bool is_nondecreasing(const std::vector<Y>& x) {
	for(typename std::vector<Y>::const_iterator i=x.begin(); i!=x.end() && i+1!=x.end(); i++) {
		if(!(i[1] >= i[0]))
			return false;
	}
	return true;
}



#endif	/* VECTOR_HELPER_HPP */

