3 * Purpose: A general purpose resizable array.
4 * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
5 * Created: January 1996
7 * Dependencies: None (almost)
9 * Copyright: 1996, Alejandro Aguilar Sierra
12 * You are free to use and modify this code under the terms of
13 * the GNU General Public Licence version 2 or later.
22 #include "mathed/support.h"
23 #include "math_defs.h"
32 /** \class MathedArray
33 \brief A resizable array.
35 A general purpose resizable array.
37 \author Alejandro Aguilar Sierra
39 \author Lars Gullik Bjønnes
40 \version February 2001
45 typedef std::vector<byte> buffer_type;
46 typedef byte value_type;
47 typedef buffer_type::size_type size_type;
48 typedef buffer_type::iterator iterator;
49 typedef buffer_type::const_iterator const_iterator;
54 MathedArray(MathedArray const &);
56 MathedArray & operator=(MathedArray const &);
65 const_iterator begin() const;
67 const_iterator end() const;
80 void swap(MathedArray &);
82 void shrink(int pos1, int pos2);
86 void insert(iterator pos, const_iterator beg, const_iterator end);
88 /// Merge \a dx elements from array \a a at \apos.
89 /// This doesn't changes the size (dangerous)
90 void merge(MathedArray const & a, int pos);
93 void raw_pointer_copy(MathedInset ** p, int pos) const;
96 void insertInset(int pos, MathedInset * p, int type);
98 MathedInset * getInset(int pos);
101 void raw_pointer_insert(void * p, int pos);
104 void strange_copy(MathedArray * dest, int dpos, int spos, int len);
106 byte operator[](int) const;
108 byte & operator[](int i);
111 void move(int p, int shift);
113 void resize(int newsize);
114 /// Make sure we can access at least \a needed elements
115 void need_size(int needed);
117 void dump(std::ostream &) const;
119 void dump2(std::ostream &) const;
120 /// creates copies of all embedded insets
123 void substitute(MathMacro *);
125 void push_back(MathedInset * inset, int t);
127 void push_back(byte, MathedTextCodes);
139 InsetTable(int p, MathedInset * i)
140 : pos(p), inset(i) {}
144 typedef std::vector<InsetTable> InsetList;
145 /// The list of insets in this array.
146 InsetList insetList_;
148 /// Last position inserted.
153 std::ostream & operator<<(std::ostream & os, MathedArray const & ar)