- Solved the proliferation of type checks for different DAI_ENUM's in properties.cpp
[libdai.git] / include / dai / diffs.h
index bf0657a..589076c 100644 (file)
@@ -41,7 +41,7 @@ class Diffs : public std::vector<double> {
             _pos = begin(); 
             _maxpos = begin(); 
         };
-        double max() { 
+        double maxDiff() { 
             if( size() < _maxsize )
                 return _def;
             else
@@ -51,7 +51,14 @@ class Diffs : public std::vector<double> {
             if( size() < _maxsize ) {
                 push_back(x);
                 _pos = end();
-                _maxpos = max_element(begin(),end());
+                if( size() > 1 ) {
+                    if( *_maxpos < back() ) {
+                        _maxpos = end();
+                        _maxpos--;
+                    }
+                } else {
+                    _maxpos = begin();
+                }
             }
             else {
                 if( _pos == end() )
@@ -66,6 +73,7 @@ class Diffs : public std::vector<double> {
                 }
             }
         }
+        size_t maxSize() { return _maxsize; }
 };