#include "insets/InsetBranch.h"
-
-namespace lyx {
-
using std::endl;
using std::lower_bound;
+namespace lyx {
+
+
namespace {
typedef InsetList::InsetTable Table;
}
-void InsetList::insert(InsetBase * inset, pos_type pos)
+void InsetList::insert(Inset * inset, pos_type pos)
{
List::iterator end = list_.end();
List::iterator it = insetIterator(pos);
}
-InsetBase * InsetList::release(pos_type pos)
+Inset * InsetList::release(pos_type pos)
{
List::iterator end = list_.end();
List::iterator it = insetIterator(pos);
if (it != end && it->pos == pos) {
- InsetBase * tmp = it->inset;
+ Inset * tmp = it->inset;
it->inset = 0;
return tmp;
}
}
-InsetBase * InsetList::get(pos_type pos) const
+Inset * InsetList::get(pos_type pos) const
{
List::const_iterator end = list_.end();
List::const_iterator it = insetIterator(pos);
}
+InsetList::InsetList(InsetList const & il)
+{
+ list_ = il.list_;
+ List::iterator it = list_.begin();
+ List::iterator end = list_.end();
+ for (; it != end; ++it)
+ it->inset = it->inset->clone();
+}
+
+
+pos_type InsetList::find(InsetCode code, pos_type startpos) const
+{
+ List::const_iterator it = insetIterator(startpos);
+ List::const_iterator end = list_.end();
+ for (; it != end ; ++it) {
+ if (it->inset->lyxCode() == code)
+ return it->pos;
+ }
+ return -1;
+}
+
+
+int InsetList::count(InsetCode code, pos_type startpos) const
+{
+ int num = 0;
+ List::const_iterator it = insetIterator(startpos);
+ List::const_iterator end = list_.end();
+ for (; it != end ; ++it) {
+ if (it->inset->lyxCode() == code)
+ ++num;
+ }
+ return num;
+}
+
} // namespace lyx