]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_data.C
oh well
[lyx.git] / src / mathed / math_data.C
index faf37c415e919cd56e8f3d8decbc846df40ebe59..7ef98e0589ddb92a862920e69aea94428a522d62 100644 (file)
@@ -66,7 +66,7 @@ void MathArray::insert(size_type pos, MathArray const & ar)
 
 
 void MathArray::push_back(MathAtom const & t)
-{      
+{
        bf_.push_back(t);
 }
 
@@ -85,7 +85,7 @@ void MathArray::clear()
 
 void MathArray::swap(MathArray & ar)
 {
-       if (this != &ar) 
+       if (this != &ar)
                bf_.swap(ar.bf_);
 }
 
@@ -176,7 +176,7 @@ void MathArray::validate(LaTeXFeatures & features) const
 
 
 void MathArray::pop_back()
-{      
+{
        if (!size()) {
                lyxerr << "pop_back from empty array!\n";
                return;
@@ -219,7 +219,7 @@ bool MathArray::matchpart(MathArray const & ar, pos_type pos) const
 {
        if (size() < ar.size() + pos)
                return false;
-       const_iterator it = begin() + pos; 
+       const_iterator it = begin() + pos;
        for (const_iterator jt = ar.begin(); jt != ar.end(); ++jt, ++it)
                if (!jt->nucleus()->match(it->nucleus()))
                        return false;
@@ -247,3 +247,24 @@ void MathArray::replace(ReplaceData & rep)
        for (const_iterator it = begin(); it != end(); ++it)
                it->nucleus()->replace(rep);
 }
+
+
+bool MathArray::contains(MathArray const & ar) const
+{
+       for (size_type i = 0; i + ar.size() <= size(); ++i) {
+               const_iterator it = begin() + i;
+               const_iterator rt = ar.begin();
+               const_iterator et = ar.end();
+               for (const_iterator jt = it; rt != et; ++jt, ++rt)
+                       if (!jt->nucleus()->match(rt->nucleus()))
+                               break;
+               if (rt == et)
+                       return true;
+       }
+
+       for (const_iterator it = begin(); it != end(); ++it)
+               if (it->nucleus()->contains(ar))
+                       return true;
+
+       return false;
+}