22 #ifndef VectorHelper_h
23 #define VectorHelper_h
50 static T
sum(
const std::vector<T>& v) {
52 for (
typename std::vector<T>::const_iterator i = v.begin(); i != v.end(); i++) {
59 if (msum == 0 || v.size() == 0) {
65 set(v, (T) 1.0 * msum / (T) v.size());
71 static void div(std::vector<T>& v, T by) {
72 for (
typename std::vector<T>::iterator i = v.begin(); i != v.end(); i++) {
78 typename std::vector<T>::iterator i = v.begin();
79 while (i != v.end()) {
80 for (
typename std::vector<T>::iterator j = i + 1; j != v.end();) {
92 static void set(std::vector<T>& v, T to) {
93 for (
typename std::vector<T>::iterator i = v.begin(); i != v.end(); i++) {
100 for (
typename std::vector<T>::const_iterator j = v.begin() ; j != v.end(); j++) {
110 for (
typename std::vector<T>::const_iterator j = v.begin(); j != v.end(); j++) {
119 for (
typename std::vector<T>::iterator j = v.begin(); j != v.end();) {
129 for (
typename std::vector<T>::iterator j = v.begin(); j != v.end();) {
138 static void add2All(std::vector<T>& v, T what) {
139 for (
typename std::vector<T>::iterator j = v.begin(); j != v.end(); j++) {
145 static bool subSetExists(
const std::vector<T>& v1,
const std::vector<T>& v2) {
146 for (
typename std::vector<T>::const_iterator i = v1.begin(); i != v1.end(); i++) {
148 if (find(v2.begin(), v2.end(), val1) != v2.end()) {
160 std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
161 for (
typename std::vector<T>::const_iterator i = v.begin(); i != v.end(); i++) {
162 if (i != v.begin()) {
static T sum(const std::vector< T > &v)
static void add2All(std::vector< T > &v, T what)
static void remove_smaller_than(std::vector< T > &v, T swell)
static T minValue(const std::vector< T > &v)
static void removeDouble(std::vector< T > &v)
static void div(std::vector< T > &v, T by)
static void normaliseSum(std::vector< T > &v, T msum=1.0)
static bool subSetExists(const std::vector< T > &v1, const std::vector< T > &v2)
Returns the information whether at least one element is within both vectors.
static void remove_larger_than(std::vector< T > &v, T swell)
static void set(std::vector< T > &v, T to)
static T maxValue(const std::vector< T > &v)