#include <ostream>
+using namespace std;
namespace lyx {
}
-void DocIterator::forwardPos(bool ignorecollapsed)
+// This duplicates code above, but is in the critical path.
+// So please think twice before adding stuff
+void DocIterator::forwardPos()
{
- //this dog bites his tail
+ // this dog bites his tail
if (empty()) {
push_back(CursorSlice(*inset_));
return;
}
- Inset * const nextinset = nextInset();
- // jump over collapsables if they are collapsed
- // FIXME: the check for asInsetMath() shouldn't be necessary
- // but math insets do not return a sensible editable() state yet.
- if (ignorecollapsed && nextinset && (!nextinset->asInsetMath()
- && nextinset->editable() != Inset::HIGHLY_EDITABLE)) {
- ++top().pos();
- return;
- }
-
CursorSlice & tip = top();
//lyxerr << "XXX\n" << *this << endl;
}
+void DocIterator::forwardPosIgnoreCollapsed()
+{
+ Inset * const nextinset = nextInset();
+ // FIXME: the check for asInsetMath() shouldn't be necessary
+ // but math insets do not return a sensible editable() state yet.
+ if (nextinset && !nextinset->asInsetMath()
+ && nextinset->editable() != Inset::HIGHLY_EDITABLE) {
+ ++top().pos();
+ return;
+ }
+ forwardPos();
+}
+
+
void DocIterator::forwardPar()
{
forwardPos();
}
-void DocIterator::cutOff(DocIterator::idx_type above, std::vector<CursorSlice> & cut)
+void DocIterator::cutOff(DocIterator::idx_type above, vector<CursorSlice> & cut)
{
- cut = std::vector<CursorSlice>(slices_.begin() + above + 1, slices_.end());
+ cut = vector<CursorSlice>(slices_.begin() + above + 1, slices_.end());
slices_.resize(above + 1);
}
}
-void DocIterator::append(std::vector<CursorSlice> const & x)
+void DocIterator::append(vector<CursorSlice> const & x)
{
slices_.insert(slices_.end(), x.begin(), x.end());
}
}
-std::ostream & operator<<(std::ostream & os, DocIterator const & dit)
+ostream & operator<<(ostream & os, DocIterator const & dit)
{
for (size_t i = 0, n = dit.depth(); i != n; ++i)
os << " " << dit[i] << "\n";
}
-bool operator<(DocIterator const & p, DocIterator const & q)
-{
- size_t depth = std::min(p.depth(), q.depth());
- for (size_t i = 0 ; i < depth ; ++i) {
- if (p[i] != q[i])
- return p[i] < q[i];
- }
- return p.depth() < q.depth();
-}
-
-
-bool operator>(DocIterator const & p, DocIterator const & q)
-{
- return q < p;
-}
-
-
-bool operator<=(DocIterator const & p, DocIterator const & q)
-{
- return !(q < p);
-}
-
-
///////////////////////////////////////////////////////
StableDocIterator::StableDocIterator(DocIterator const & dit)
}
-std::ostream & operator<<(std::ostream & os, StableDocIterator const & dit)
+ostream & operator<<(ostream & os, StableDocIterator const & dit)
{
for (size_t i = 0, n = dit.data_.size(); i != n; ++i)
os << " " << dit.data_[i] << "\n";