#include <VectorHelper.h>
Definition at line 52 of file VectorHelper.h.
Static Public Member Functions | |
| static void | add2All (std::vector< T > &v, T what) |
| static void | div (std::vector< T > &v, T by) |
| static T | maxValue (const std::vector< T > &v) |
| static T | minValue (const std::vector< T > &v) |
| static void | normalise (std::vector< T > &v, T msum=1.0) |
| static void | remove_larger_than (std::vector< T > &v, T swell) |
| static void | remove_smaller_than (std::vector< T > &v, T swell) |
| static void | removeDouble (std::vector< T > &v) |
| static void | set (std::vector< T > &v, T to) |
| 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 T | sum (const std::vector< T > &v) |
| static void VectorHelper< T >::add2All | ( | std::vector< T > & | v, | |
| T | what | |||
| ) | [inline, static] |
Definition at line 142 of file VectorHelper.h.
Referenced by Position2DVector::intersectsAtLengths().
00142 { 00143 for (typename std::vector<T>::iterator j=v.begin(); j!=v.end(); j++) { 00144 (*j) += what; 00145 } 00146 }
| static void VectorHelper< T >::div | ( | std::vector< T > & | v, | |
| T | by | |||
| ) | [inline, static] |
Definition at line 75 of file VectorHelper.h.
Referenced by VectorHelper< T >::normalise().
00075 { 00076 for (typename std::vector<T>::iterator i=v.begin(); i!=v.end(); i++) { 00077 *i /= by; 00078 } 00079 }
| static T VectorHelper< T >::maxValue | ( | const std::vector< T > & | v | ) | [inline, static] |
Definition at line 102 of file VectorHelper.h.
References SUMOReal.
Referenced by NBEdge::computeEdgeShape(), and NBEdge::isNearEnough2BeJoined2().
00102 { 00103 SUMOReal m = *(v.begin()); 00104 for (typename std::vector<T>::const_iterator j=v.begin()+1; j!=v.end(); j++) { 00105 if ((*j)>m) { 00106 m = *j; 00107 } 00108 } 00109 return m; 00110 }
| static T VectorHelper< T >::minValue | ( | const std::vector< T > & | v | ) | [inline, static] |
Definition at line 112 of file VectorHelper.h.
References SUMOReal.
Referenced by NBEdge::computeEdgeShape().
00112 { 00113 SUMOReal m = *(v.begin()); 00114 for (typename std::vector<T>::const_iterator j=v.begin()+1; j!=v.end(); j++) { 00115 if ((*j)<m) { 00116 m = *j; 00117 } 00118 } 00119 return m; 00120 }
| static void VectorHelper< T >::normalise | ( | std::vector< T > & | v, | |
| T | msum = 1.0 | |||
| ) | [inline, static] |
Definition at line 62 of file VectorHelper.h.
References VectorHelper< T >::div(), and VectorHelper< T >::sum().
00062 { 00063 if (msum==0) { 00064 // is an error; do nothing 00065 return; 00066 } 00067 T rsum = sum(v); 00068 if (rsum==0) { 00069 set(v, (T) 1.0/msum/(T) v.size()); 00070 return; 00071 } 00072 div(v, rsum/msum); 00073 }
| static void VectorHelper< T >::remove_larger_than | ( | std::vector< T > & | v, | |
| T | swell | |||
| ) | [inline, static] |
Definition at line 132 of file VectorHelper.h.
00132 { 00133 for (typename std::vector<T>::iterator j=v.begin(); j!=v.end();) { 00134 if ((*j)>swell) { 00135 j = v.erase(j); 00136 } else { 00137 j++; 00138 } 00139 } 00140 }
| static void VectorHelper< T >::remove_smaller_than | ( | std::vector< T > & | v, | |
| T | swell | |||
| ) | [inline, static] |
Definition at line 122 of file VectorHelper.h.
00122 { 00123 for (typename std::vector<T>::iterator j=v.begin(); j!=v.end();) { 00124 if ((*j)<swell) { 00125 j = v.erase(j); 00126 } else { 00127 j++; 00128 } 00129 } 00130 }
| static void VectorHelper< T >::removeDouble | ( | std::vector< T > & | v | ) | [inline, static] |
Definition at line 81 of file VectorHelper.h.
Referenced by NIVissimConnectionCluster::add(), NIVissimEdge::buildConnectionClusters(), and NIVissimConnectionCluster::NIVissimConnectionCluster().
00081 { 00082 typename std::vector<T>::iterator i=v.begin(); 00083 while (i!=v.end()) { 00084 for (typename std::vector<T>::iterator j=i+1; j!=v.end();) { 00085 if (*i==*j) { 00086 j = v.erase(j); 00087 } else { 00088 j++; 00089 } 00090 } 00091 i++; 00092 } 00093 }
| static void VectorHelper< T >::set | ( | std::vector< T > & | v, | |
| T | to | |||
| ) | [inline, static] |
Definition at line 96 of file VectorHelper.h.
00096 { 00097 for (typename std::vector<T>::iterator i=v.begin(); i!=v.end(); i++) { 00098 *i = to; 00099 } 00100 }
| static bool VectorHelper< T >::subSetExists | ( | const std::vector< T > & | v1, | |
| const std::vector< T > & | v2 | |||
| ) | [inline, static] |
Returns the information whether at least one element is within both vectors.
Definition at line 149 of file VectorHelper.h.
00149 { 00150 for (typename std::vector<T>::const_iterator i=v1.begin(); i!=v1.end(); i++) { 00151 int val1 = (*i); 00152 if (find(v2.begin(), v2.end(), val1)!=v2.end()) { 00153 return true; 00154 } 00155 } 00156 return false; 00157 }
| static T VectorHelper< T >::sum | ( | const std::vector< T > & | v | ) | [inline, static] |
Definition at line 54 of file VectorHelper.h.
Referenced by VectorHelper< T >::normalise().
00054 { 00055 T sum = 0; 00056 for (typename std::vector<T>::const_iterator i=v.begin(); i!=v.end(); i++) { 00057 sum += *i; 00058 } 00059 return sum; 00060 }
1.5.6