]> git.lyx.org Git - features.git/commitdiff
mathed17.diff + some iterator methods
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 14 Feb 2001 17:50:58 +0000 (17:50 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 14 Feb 2001 17:50:58 +0000 (17:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1512 a592a061-630c-0410-9148-cb99ea01b6c8

po/POTFILES.in
src/mathed/ChangeLog
src/mathed/array.C
src/mathed/array.h
src/mathed/math_xiter.C

index cf8fdaa1f242c0964d62dc2abbaad1b747ce3e11..7739bbbcca23b7d8e00e8f911f538ec33579fb79 100644 (file)
@@ -66,44 +66,44 @@ src/frontends/kde/tocdlg.C
 src/frontends/kde/urldlg.C
 src/frontends/qt2/FormCopyright.C
 src/frontends/xforms/FormBase.h
-src/frontends/xforms/FormBibitem.C
 src/frontends/xforms/form_bibitem.C
-src/frontends/xforms/FormBibtex.C
+src/frontends/xforms/FormBibitem.C
 src/frontends/xforms/form_bibtex.C
+src/frontends/xforms/FormBibtex.C
 src/frontends/xforms/form_browser.C
-src/frontends/xforms/FormCitation.C
 src/frontends/xforms/form_citation.C
-src/frontends/xforms/FormCopyright.C
+src/frontends/xforms/FormCitation.C
 src/frontends/xforms/form_copyright.C
-src/frontends/xforms/FormDocument.C
+src/frontends/xforms/FormCopyright.C
 src/frontends/xforms/form_document.C
-src/frontends/xforms/FormError.C
+src/frontends/xforms/FormDocument.C
 src/frontends/xforms/form_error.C
-src/frontends/xforms/FormGraphics.C
+src/frontends/xforms/FormError.C
 src/frontends/xforms/form_graphics.C
-src/frontends/xforms/FormInclude.C
+src/frontends/xforms/FormGraphics.C
 src/frontends/xforms/form_include.C
-src/frontends/xforms/FormIndex.C
+src/frontends/xforms/FormInclude.C
 src/frontends/xforms/form_index.C
+src/frontends/xforms/FormIndex.C
 src/frontends/xforms/FormInset.h
 src/frontends/xforms/FormLog.C
-src/frontends/xforms/FormParagraph.C
 src/frontends/xforms/form_paragraph.C
-src/frontends/xforms/FormPreferences.C
+src/frontends/xforms/FormParagraph.C
 src/frontends/xforms/form_preferences.C
-src/frontends/xforms/FormPrint.C
+src/frontends/xforms/FormPreferences.C
 src/frontends/xforms/form_print.C
-src/frontends/xforms/FormRef.C
+src/frontends/xforms/FormPrint.C
 src/frontends/xforms/form_ref.C
+src/frontends/xforms/FormRef.C
 src/frontends/xforms/FormSplash.C
-src/frontends/xforms/FormTabular.C
 src/frontends/xforms/form_tabular.C
-src/frontends/xforms/FormTabularCreate.C
+src/frontends/xforms/FormTabular.C
 src/frontends/xforms/form_tabular_create.C
-src/frontends/xforms/FormToc.C
+src/frontends/xforms/FormTabularCreate.C
 src/frontends/xforms/form_toc.C
-src/frontends/xforms/FormUrl.C
+src/frontends/xforms/FormToc.C
 src/frontends/xforms/form_url.C
+src/frontends/xforms/FormUrl.C
 src/frontends/xforms/FormVCLog.C
 src/frontends/xforms/input_validators.C
 src/frontends/xforms/Menubar_pimpl.C
index 090344a9f84e3d8065aeaa79de39cd5b2333f2c7..2314eadfba72ff2a545d076e15cd125009b80f76 100644 (file)
@@ -1,3 +1,12 @@
+2001-02-14  Lars Gullik Bjønnes  <larsbj@lyx.org>
+
+       * array.C (begin): new method
+       (end): ditto
+
+2001-02-14  André Pönitz  <poenitz@htwm.de>
+       
+       * math_iter.[Ch]: remove 'insert', 'maxsize' and 'ARRAY_SIZE'
+
 2001-02-14  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * math_spaceinset.C: 
@@ -13,7 +22,7 @@
        * math_accentinset.C: 
        * math_sqrtinset.C: include LOstream.h and add using directive.
 
-2001-02-12  André Pönitz  <poenitz@htwm.de>
+2001-02-14  André Pönitz  <poenitz@htwm.de>
 
        * math_iter.C: reformatting 
 
index 060effb04679aff0bf3710346dd51f002dcc0daf..245b801a2f0f99f75a0cd678dbf3eca396aff7b4 100644 (file)
@@ -18,6 +18,38 @@ void * my_memcpy(void * ps_in, void const * pt_in, size_t n)
 }
 
 
+MathedArray::MathedArray(int size)
+       : last_(0)
+{
+       int const newsize = (size < ARRAY_MIN_SIZE) ? ARRAY_MIN_SIZE : size;
+       bf_.resize(newsize);
+}
+
+
+MathedArray::iterator MathedArray::begin() 
+{
+       return bf_.begin();
+}
+
+
+MathedArray::iterator MathedArray::end() 
+{
+       return bf_.end();
+}
+
+
+MathedArray::const_iterator MathedArray::begin() const
+{
+       return bf_.begin();
+}
+
+
+MathedArray::const_iterator MathedArray::end() const
+{
+       return bf_.end();
+}
+
+
 int MathedArray::empty() const
 {
        return (last_ == 0);
@@ -36,15 +68,9 @@ void MathedArray::last(int l)
 }
 
 
-int MathedArray::maxsize() const
-{
-       return static_cast<int>(bf_.size());
-}
-
-
 void MathedArray::need_size(int needed)
 {
-       if (needed >= maxsize()) 
+       if (needed >= static_cast<int>(bf_.size()))
                resize(needed);
 }
 
@@ -55,19 +81,12 @@ void MathedArray::resize(int newsize)
                newsize = ARRAY_MIN_SIZE;
        newsize += ARRAY_STEP - (newsize % ARRAY_STEP);
        bf_.resize(newsize);
-       if (last_ >= newsize) last_ = newsize - 1;
+       if (last_ >= newsize)
+               last_ = newsize - 1;
        bf_[last_] = 0;
 }
 
 
-MathedArray::MathedArray(int size) 
-{
-       int newsize = (size < ARRAY_MIN_SIZE) ? ARRAY_MIN_SIZE : size;
-       bf_.resize(newsize);
-       last_ = 0;
-}
-
-
 void MathedArray::move(int p, int shift)
 {
        if (p <= last_) {
@@ -79,10 +98,20 @@ void MathedArray::move(int p, int shift)
 }
 
 
+#if 0
+void MathedArray::insert(MathedArray::iterator pos,
+                        MathedArray::const_iterator beg,
+                        MathedArray::const_iterator end)
+{
+       bf_.insert(pos, beg, end);
+       last_ = bf_.size() - 1;
+}
+#else
 void MathedArray::mergeF(MathedArray * a, int p, int dx)
 {
        my_memcpy(&bf_[p], &a->bf_[0], dx);
 }
+#endif
 
 
 void MathedArray::raw_pointer_copy(MathedInset ** p, int pos) const
@@ -114,17 +143,3 @@ byte & MathedArray::operator[](int i)
 {
        return bf_[i];
 }
-
-
-void MathedArray::insert(int pos, byte c)
-{
-       if (pos < 0) pos = last_;
-
-       // I think this should be replaced by  need_size(pos).  Note that the
-       // current code looks troublesome if  pos > maxsize() + ARRAY_STEP.
-       if (pos >= maxsize()) 
-               resize(maxsize() + ARRAY_STEP);
-       bf_[pos] = c;
-       if (pos >= last_)
-               last_ = pos + 1;
-}
index 7801fcd7ddafd8811f41326b54864d1cbc54a8d0..c9d042587a016635fc67f666725629f627bccdef 100644 (file)
@@ -42,10 +42,11 @@ public:
        typedef std::vector<byte>         buffer_type;
        typedef byte                      value_type;
        typedef buffer_type::size_type    size_type;
+       typedef buffer_type::iterator iterator;
+       typedef buffer_type::const_iterator const_iterator;
+       
        ///
        enum {
-               ///
-               ARRAY_SIZE = 256,
                ///
                ARRAY_STEP = 16,
                ///
@@ -56,6 +57,15 @@ public:
        explicit
        MathedArray(int size = ARRAY_STEP);
 
+       ///
+       iterator begin();
+       ///
+       iterator end();
+       ///
+       const_iterator begin() const;
+       ///
+       const_iterator end() const;
+       
        ///
        int empty() const;
    
@@ -63,14 +73,15 @@ public:
        int last() const;
        ///
        void last(int l);
-   
+
+#if 0
+       ///
+       void insert(iterator pos, const_iterator beg, const_iterator end);
+#else
        /// Merge \a dx elements from array \a a at \apos.
        /// This doesn't changes the size (dangerous)
        void mergeF(MathedArray * a, int pos, int dx); 
-
-       /// Insert a character at position \a pos
-       void insert(int pos, byte);
-
+#endif
        ///
        void raw_pointer_copy(MathedInset ** p, int pos) const;
        ///
@@ -86,12 +97,9 @@ public:
        void move(int p, int shift);
        ///
        void resize(int newsize);
-       ///
-       int maxsize() const;
        /// Make sure we can access at least \a needed elements
        void need_size(int needed);
 private:
-
        /// Buffer
        buffer_type bf_;
        /// Last position inserted.
index 046257659f3b024c0a11a0bf50e1f957b05118f2..40ca0eba33401bb31980ee44aa6f4f560c0a225b 100644 (file)
@@ -137,11 +137,15 @@ void MathedXIter::Merge(MathedArray * a0)
        // All insets must be clonned
        MathedIter it(a0);
        MathedArray * a = it.Copy();
-       
+
+#if 0
+       array->insert(array->begin() + pos,
+                     a->begin(), a->end());
+#else
        // make room for the data 
        split(a->last());
        array->mergeF(a, pos, a->last());
-       
+#endif
        int pos1 = pos;
        int pos2 = pos + a->last();