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 "math_atom.h"
35 \brief Low level container for math insets
37 \author Alejandro Aguilar Sierra
39 \author Lars Gullik Bjønnes
40 \version February 2001
43 class MathArray : private std::vector<MathAtom> {
45 /// re-use inhertited stuff
46 typedef std::vector<MathAtom> base_type;
47 using base_type::const_iterator;
48 using base_type::iterator;
49 using base_type::size_type;
50 using base_type::difference_type;
51 using base_type::size;
52 using base_type::empty;
53 using base_type::clear;
54 using base_type::begin;
56 using base_type::push_back;
57 using base_type::pop_back;
58 using base_type::back;
59 using base_type::front;
60 using base_type::swap;
62 typedef size_type idx_type;
63 typedef size_type pos_type;
69 MathArray(const_iterator from, const_iterator to);
71 void append(MathArray const & ar);
73 /// inserts single atom at position pos
74 void insert(size_type pos, MathAtom const & at);
75 /// inserts multiple atoms at position pos
76 void insert(size_type pos, MathArray const & ar);
78 /// erase range from pos1 to pos2
79 void erase(iterator pos1, iterator pos2);
81 void erase(iterator pos);
82 /// erase range from pos1 to pos2
83 void erase(size_type pos1, size_type pos2);
85 void erase(size_type pos);
92 void substitute(MathMacro const & macro);
94 void replace(ReplaceData &);
96 /// looks for exact match
97 bool match(MathArray const & ar) const;
98 /// looks for inclusion match starting at pos
99 bool matchpart(MathArray const & ar, pos_type pos) const;
100 /// looks for containment, return == size mean not found
101 size_type find(MathArray const & ar) const;
102 /// looks for containment, return == size mean not found
103 size_type find_last(MathArray const & ar) const;
105 bool contains(MathArray const & ar) const;
107 void validate(LaTeXFeatures &) const;
109 /// checked write access
110 MathAtom & operator[](pos_type);
111 /// checked read access
112 MathAtom const & operator[](pos_type) const;
114 /// is this an exact match at this position?
115 bool find1(MathArray const & ar, size_type pos) const;
119 std::ostream & operator<<(std::ostream & os, MathArray const & ar);