return !(i1 == i2);
}
+////////// The ParagraphList::const_iterator
+
+ParagraphList::const_iterator::const_iterator()
+ : ptr(0)
+{}
+
+
+ParagraphList::const_iterator::const_iterator(Paragraph * p)
+ : ptr(p)
+{}
+
+
+ParagraphList::const_iterator::const_reference
+ParagraphList::const_iterator::operator*()
+{
+ return *ptr;
+}
+
+
+ParagraphList::const_iterator::const_pointer
+ParagraphList::const_iterator::operator->()
+{
+ return ptr;
+}
+
+
+ParagraphList::const_iterator &
+ParagraphList::const_iterator::operator++()
+{
+ ptr = ptr->next_par_;
+ return *this;
+}
+
+
+ParagraphList::const_iterator
+ParagraphList::const_iterator::operator++(int)
+{
+ const_iterator tmp = *this;
+ ++*this;
+ return tmp;
+}
+
+
+ParagraphList::const_iterator &
+ParagraphList::const_iterator::operator--()
+{
+ ptr = ptr->prev_par_;
+ return *this;
+}
+
+
+ParagraphList::const_iterator
+ParagraphList::const_iterator::operator--(int)
+{
+ const_iterator tmp = *this;
+ --*this;
+ return tmp;
+}
+
+
+bool operator==(ParagraphList::const_iterator const & i1,
+ ParagraphList::const_iterator const & i2)
+{
+ return &(*const_cast<ParagraphList::const_iterator&>(i1))
+ == &(*const_cast<ParagraphList::const_iterator&>(i2));
+}
+
+
+bool operator!=(ParagraphList::const_iterator const & i1,
+ ParagraphList::const_iterator const & i2)
+{
+ return !(i1 == i2);
+}
+
//////////
////////// The ParagraphList proper
//////////
: parlist(0)
{
// Deep copy.
- ParagraphList::iterator it = pl.begin();
- ParagraphList::iterator end = pl.end();
+ ParagraphList::const_iterator it = pl.begin();
+ ParagraphList::const_iterator end = pl.end();
for (; it != end; ++it) {
push_back(*it);
}
ParagraphList::iterator
-ParagraphList::insert(ParagraphList::iterator it, Paragraph * par)
+ParagraphList::insert(ParagraphList::iterator it, Paragraph const & p)
{
+ Paragraph * par = new Paragraph(p);
+
if (it != end()) {
Paragraph * prev = it->prev_par_;
par->next_par_ = &*it;
void ParagraphList::insert(iterator pos, iterator beg, iterator end)
{
for (; beg != end; ++beg) {
- insert(pos, new Paragraph(*beg, false));
+ insert(pos, *beg);
}
}
}
-ParagraphList::iterator ParagraphList::begin() const
+ParagraphList::const_iterator ParagraphList::begin() const
{
- return iterator(parlist);
+ return const_iterator(parlist);
}
}
-ParagraphList::iterator ParagraphList::end() const
+ParagraphList::const_iterator ParagraphList::end() const
{
- return iterator();
+ return const_iterator();
}
void ParagraphList::push_back(Paragraph const & pr)
{
- Paragraph * p = new Paragraph(pr, false);
+ Paragraph * p = new Paragraph(pr);
if (!parlist) {
parlist = p;