]> git.lyx.org Git - features.git/commitdiff
get rid of NO_NEXT add some NO_STD_LIST instead
authorLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 23 May 2003 22:42:14 +0000 (22:42 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 23 May 2003 22:42:14 +0000 (22:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7035 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/ParagraphList.C
src/ParagraphList.h
src/paragraph.C
src/paragraph.h

index 51bb95b09cef3332cf227bd01c95294335594fdd..32208912a17df29cb24e029beebba5e72364ef9b 100644 (file)
@@ -1,3 +1,16 @@
+2003-05-24  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * paragraph.h: add NO_STD_LIST define, remove NO_NEXT define.
+
+       * paragraph.C: remove all NO_NEXT node add some NO_STD_LIST parts
+       instead. 
+
+       * ParagraphList.h: degenerate to std::list if NO_STD_LIST is not
+       set else use old code.
+
+       * ParagraphList.C: remove all NO_NEXT code and only compile this
+       code of NO_STD_LIST is set.
+
 2003-05-23  Alfredo Braunstein  <abraunst@libero.it>
 
        * BufferView_pimpl.C:
@@ -20,7 +33,7 @@
 
 2003-05-23  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
-       * ParagraphList.h (set): remove unused function. 
+       * ParagraphList.h (set): remove unused function.
 
 2003-05-23  André Pönitz  <poenitz@gmx.net>
 
index 86450c14ad6509ae724e3c461ee0bb01c15fb95d..e375f0836fd838ef5480749fee07796c6ed190f2 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "paragraph.h"
 
+#ifdef NO_STD_LIST
+
 ////////// The ParagraphList::iterator
 
 ParagraphList::iterator::iterator()
@@ -33,11 +35,7 @@ ParagraphList::iterator::operator->()
 ParagraphList::iterator &
 ParagraphList::iterator::operator++()
 {
-#ifndef NO_NEXT
-       ptr = ptr->next_;
-#else
        ptr = ptr->next_par_;
-#endif
        return *this;
 }
 
@@ -54,11 +52,7 @@ ParagraphList::iterator::operator++(int)
 ParagraphList::iterator &
 ParagraphList::iterator::operator--()
 {
-#ifndef NO_NEXT
-       ptr = ptr->previous_;
-#else
        ptr = ptr->prev_par_;
-#endif
        return *this;
 }
 
@@ -118,25 +112,6 @@ ParagraphList & ParagraphList::operator=(ParagraphList const & rhs)
 ParagraphList::iterator
 ParagraphList::insert(ParagraphList::iterator it, Paragraph * par)
 {
-#ifndef NO_NEXT
-       if (it != end()) {
-               Paragraph * prev = it->previous_;
-               par->next_ = &*it;
-               par->previous_ = prev;
-               prev->next_ = par;
-               it->previous_ = par;
-       } else if (parlist == 0) {
-               parlist = par;
-       } else {
-               // Find last par.
-               Paragraph * last = parlist;
-               while (last->next_)
-                       last = last->next_;
-               last->next_ = par;
-               par->previous_ = last;
-       }
-       return iterator(par);
-#else
        if (it != end()) {
                Paragraph * prev = it->prev_par_;
                par->next_par_ = &*it;
@@ -154,7 +129,6 @@ ParagraphList::insert(ParagraphList::iterator it, Paragraph * par)
                par->prev_par_ = last;
        }
        return iterator(par);
-#endif
 }
 
 
@@ -183,33 +157,6 @@ void ParagraphList::splice(iterator pos, ParagraphList & pl)
 
        Paragraph * first = pl.parlist;
        Paragraph * last = first;
-#ifndef NO_NEXT
-       while (last->next_)
-               last = last->next_;
-
-       if (pos == end()) {
-               if (parlist == 0) {
-                       parlist = first;
-               } else {
-                       Paragraph * last_par = &back();
-                       last_par->next_ = first;
-                       first->previous_ = last_par;
-               }
-       } else if (pos == begin()) {
-               last->next_ = parlist;
-               parlist->previous_ = last;
-               parlist = first;
-       } else {
-               Paragraph * pos_par = &*pos;
-               Paragraph * before_pos = pos_par->previous_;
-
-               before_pos->next_ = first;
-               first->previous_ = before_pos;
-               last->next_ = pos_par;
-               pos_par->previous_ = last;
-       }
-       pl.parlist = 0;
-#else
        while (last->next_par_)
                last = last->next_par_;
 
@@ -235,47 +182,21 @@ void ParagraphList::splice(iterator pos, ParagraphList & pl)
                pos_par->prev_par_ = last;
        }
        pl.parlist = 0;
-#endif
 }
 
 
 void ParagraphList::clear()
 {
-#ifndef NO_NEXT
-       while (parlist) {
-               Paragraph * tmp = parlist->next_;
-               delete parlist;
-               parlist = tmp;
-       }
-#else
        while (parlist) {
                Paragraph * tmp = parlist->next_par_;
                delete parlist;
                parlist = tmp;
        }
-#endif
 }
 
 
 ParagraphList::iterator ParagraphList::erase(ParagraphList::iterator it)
 {
-#ifndef NO_NEXT
-       Paragraph * prev = it->previous_;
-       Paragraph * next = it->next_;
-
-       if (prev)
-               prev->next_ = next;
-       else
-               parlist = next;
-
-       if (next)
-               next->previous_ = prev;
-
-       it->previous_ = 0;
-       it->next_ = 0;
-       delete &*it;
-       return next;
-#else
        Paragraph * prev = it->prev_par_;
        Paragraph * next = it->next_par_;
 
@@ -289,7 +210,6 @@ ParagraphList::iterator ParagraphList::erase(ParagraphList::iterator it)
 
        delete &*it;
        return next;
-#endif
 }
 
 
@@ -341,50 +261,24 @@ Paragraph & ParagraphList::front()
 
 Paragraph const & ParagraphList::back() const
 {
-#ifndef NO_NEXT
-       Paragraph * tmp = parlist;
-       while (tmp->next_)
-               tmp = tmp->next_;
-       return *tmp;
-#else
        Paragraph * tmp = parlist;
        while (tmp->next_par_)
                tmp = tmp->next_par_;
        return *tmp;
-#endif
 }
 
 
 Paragraph & ParagraphList::back()
 {
-#ifndef NO_NEXT
-       Paragraph * tmp = parlist;
-       while (tmp->next_)
-               tmp = tmp->next_;
-       return *tmp;
-#else
        Paragraph * tmp = parlist;
        while (tmp->next_par_)
                tmp = tmp->next_par_;
        return *tmp;
-#endif
 }
 
 
 void ParagraphList::push_back(Paragraph * p)
 {
-#ifndef NO_NEXT
-       if (!parlist) {
-               parlist = p;
-               return;
-       }
-
-       Paragraph * pos = parlist;
-       while (pos->next_)
-               pos = pos->next_;
-       pos->next_ = p;
-       p->previous_ = pos;
-#else
        if (!parlist) {
                parlist = p;
                return;
@@ -395,23 +289,11 @@ void ParagraphList::push_back(Paragraph * p)
                pos = pos->next_par_;
        pos->next_par_ = p;
        p->prev_par_ = pos;
-#endif
 }
 
 
 int ParagraphList::size() const
 {
-#ifndef NO_NEXT
-       // When we switch to a std::container this will be O(1)
-       // instead of O(n). (Lgb)
-       Paragraph * tmp = parlist;
-       int c = 0;
-       while (tmp) {
-               ++c;
-               tmp = tmp->next_;
-       }
-       return c;
-#else
        // When we switch to a std::container this will be O(1)
        // instead of O(n). (Lgb)
        Paragraph * tmp = parlist;
@@ -421,7 +303,6 @@ int ParagraphList::size() const
                tmp = tmp->next_par_;
        }
        return c;
-#endif
 }
 
 
@@ -429,3 +310,5 @@ bool ParagraphList::empty() const
 {
        return parlist == 0;
 }
+
+#endif
index 08f60640a532ae2a1f1cb9e1c6fe21b53f6abdb5..38b6ede88b4de8ff6fc11446533236473c795066 100644 (file)
@@ -3,11 +3,23 @@
 #ifndef PARAGRAPH_LIST_H
 #define PARAGRAPH_LIST_H
 
-#include <iterator>
-#include <utility>
+#define NO_STD_LIST 1
+
+#ifndef NO_STD_LIST
+
+#include "paragraph.h"
+
+#include <list>
+
+typedef std::list<Paragraph> ParagraphList;
+
+#else
 
 class Paragraph;
 
+#include <iterator>
+#include <utility>
+
 ///
 class ParagraphList {
 public:
@@ -104,5 +116,6 @@ bool operator==(ParagraphList::iterator const & i1,
 bool operator!=(ParagraphList::iterator const & i1,
                ParagraphList::iterator const & i2);
 
+#endif
 
 #endif
index 4d87ad7ba815a04b408ac114148589f5819f0718..605330f2ff6922b74dadd4d0006bb9a5db8ec95d 100644 (file)
@@ -73,10 +73,7 @@ extern BufferView * current_view;
 Paragraph::Paragraph()
        : pimpl_(new Paragraph::Pimpl(this))
 {
-#ifndef NO_NEXT
-       next_ = 0;
-       previous_ = 0;
-#else
+#ifdef NO_STD_LIST
        next_par_ = 0;
        prev_par_ = 0;
 #endif
@@ -91,10 +88,7 @@ Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
 {
        enumdepth = 0;
        itemdepth = 0;
-#ifndef NO_NEXT
-       next_     = 0;
-       previous_ = 0;
-#else
+#ifdef NO_STD_LIST
        next_par_ = 0;
        prev_par_ = 0;
 #endif
@@ -118,13 +112,6 @@ Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
 // the destructor removes the new paragraph from the list
 Paragraph::~Paragraph()
 {
-#ifndef NO_NEXT
-       if (previous_)
-               previous_->next_ = next_;
-       if (next_)
-               next_->previous_ = previous_;
-#endif
-
        delete pimpl_;
        //
        //lyxerr << "Paragraph::paragraph_id = "
@@ -612,47 +599,6 @@ void Paragraph::setFont(pos_type pos, LyXFont const & font)
 }
 
 
-#ifndef NO_NEXT
-void Paragraph::next(Paragraph * p)
-{
-       next_ = p;
-}
-
-
-// This function is able to hide closed footnotes.
-Paragraph * Paragraph::next()
-{
-       return next_;
-}
-
-
-Paragraph const * Paragraph::next() const
-{
-       return next_;
-}
-
-
-void Paragraph::previous(Paragraph * p)
-{
-       previous_ = p;
-}
-
-
-// This function is able to hide closed footnotes.
-Paragraph * Paragraph::previous()
-{
-       return previous_;
-}
-
-
-// This function is able to hide closed footnotes.
-Paragraph const * Paragraph::previous() const
-{
-       return previous_;
-}
-#endif
-
-
 void Paragraph::makeSameLayout(Paragraph const & par)
 {
        layout(par.layout());
index 3b822aa561fab778693599a2fd16f20d7ea59033..31362d94c53354eb12e3607492582bb4db4ec94f 100644 (file)
@@ -34,15 +34,16 @@ class TexRow;
 // Define this if you want to try out the new storage container for
 // paragraphs. (Lgb)
 // This is non working and far from finished.
-#define NO_NEXT 1
+#define NO_STD_LIST 1
 
 /// A Paragraph holds all text, attributes and insets in a text paragraph
 class Paragraph  {
 public:
+#ifdef NO_STD_LIST
        // Remove this whan ParagraphList transition is over. (Lgb)
        friend class ParagraphList;
        friend class ParagraphList::iterator;
-
+#endif
        ///
        enum META_KIND {
                /// Note that this is 1 right now to avoid
@@ -140,23 +141,6 @@ public:
        ///
        InsetBibitem * bibitem();  // ale970302
 
-#ifndef NO_NEXT
-       ///
-       void next(Paragraph *);
-       /** these function are able to hide closed footnotes
-        */
-       Paragraph * next();
-       ///
-       Paragraph const * next() const;
-
-       ///
-       void previous(Paragraph *);
-       ///
-       Paragraph * previous();
-       ///
-       Paragraph const * previous() const;
-#endif
-
        /// initialise tracking for this par
        void trackChanges(Change::Type = Change::UNCHANGED);
 
@@ -318,12 +302,7 @@ private:
        LyXLayout_ptr layout_;
        /// if anything uses this we don't want it to.
        Paragraph(Paragraph const &);
-#ifndef NO_NEXT
-       ///
-       Paragraph * next_;
-       ///
-       Paragraph * previous_;
-#else
+#ifdef NO_STD_LIST
        Paragraph * next_par_;
        Paragraph * prev_par_;
 #endif