-MathArray::MathArray(MathArray const & array, int from, int to)
+MathArray::MathArray(MathArray const & array, size_type from, size_type to)
: bf_(array.begin() + from, array.begin() + to)
{}
: bf_(array.begin() + from, array.begin() + to)
{}
-int MathArray::last() const
-{
- return size() - 1;
-}
-
-
void MathArray::substitute(MathMacro const & m)
{
for (iterator it = begin(); it != end(); ++it)
void MathArray::substitute(MathMacro const & m)
{
for (iterator it = begin(); it != end(); ++it)
-MathAtom * MathArray::at(int pos)
+MathAtom * MathArray::at(size_type pos)
- return (0 <= pos && pos < size()) ? &bf_[pos] : 0;
+ return pos < size() ? &bf_[pos] : 0;
-MathAtom const * MathArray::at(int pos) const
+MathAtom const * MathArray::at(size_type pos) const
- return (0 <= pos && pos < size()) ? &bf_[pos] : 0;
+ return pos < size() ? &bf_[pos] : 0;
-void MathArray::insert(int pos, MathInset * p)
+void MathArray::insert(size_type pos, MathInset * p)
{
//cerr << "\n 1: "; p->write(cerr, true); cerr << p << "\n";
// inserting here invalidates the pointer!
{
//cerr << "\n 1: "; p->write(cerr, true); cerr << p << "\n";
// inserting here invalidates the pointer!
-void MathArray::insert(int pos, MathArray const & array)
+void MathArray::insert(size_type pos, MathArray const & array)
{
bf_.insert(begin() + pos, array.begin(), array.end());
}
{
bf_.insert(begin() + pos, array.begin(), array.end());
}
-int MathArray::size() const
+MathArray::size_type MathArray::size() const
-void MathArray::erase(int pos)
+void MathArray::erase(size_type pos)
{
if (pos < size())
erase(pos, pos + 1);
}
{
if (pos < size())
erase(pos, pos + 1);
}
-void MathArray::erase(int pos1, int pos2)
+void MathArray::erase(size_type pos1, size_type pos2)
{
bf_.erase(begin() + pos1, begin() + pos2);
}
{
bf_.erase(begin() + pos1, begin() + pos2);
}
typedef buffer_type::const_iterator const_iterator;
///
typedef buffer_type::iterator iterator;
typedef buffer_type::const_iterator const_iterator;
///
typedef buffer_type::iterator iterator;
+ ///
+ typedef buffer_type::size_type size_type;
public:
///
MathArray();
///
public:
///
MathArray();
///
- MathArray(MathArray const &, int from, int to);
+ MathArray(MathArray const &, size_type from, size_type to);
+ size_type size() const;
///
bool empty() const;
///
///
bool empty() const;
///
void swap(MathArray &);
///
void swap(MathArray &);
///
- void insert(int pos, MathInset * inset);
+ void insert(size_type pos, MathInset * inset);
- void insert(int pos, MathArray const &);
+ void insert(size_type pos, MathArray const &);
- void erase(int pos1, int pos2);
+ void erase(size_type pos1, size_type pos2);
+ void erase(size_type pos);
- ///
- int last() const;
-
///
void push_back(MathInset * inset);
///
void push_back(MathInset * inset);
void substitute(MathMacro const &);
///
void substitute(MathMacro const &);
///
- MathAtom * at(int pos);
+ MathAtom * at(size_type pos);
- MathAtom const * at(int pos) const;
+ MathAtom const * at(size_type pos) const;
///
void write(std::ostream &, bool) const;
///
///
void write(std::ostream &, bool) const;
///
class MathInset {
public:
class MathInset {
public:
+ ///
+ typedef MathArray::size_type size_type;
+
///
MathInset();
/// the virtual base destructor
///
MathInset();
/// the virtual base destructor
bool MathNestInset::idxEnd(int & idx, int & pos) const
{
bool MathNestInset::idxEnd(int & idx, int & pos) const
{
- if (pos == cell(idx).size())
+ int n = cell(idx).size();
+ if (pos == n)
- pos = cell(idx).size();
width_ = 0;
//lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
width_ = 0;
//lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
- for (int pos = 0; pos < data_.size(); ++pos) {
+ for (size_type pos = 0; pos < data_.size(); ++pos) {
MathAtom const * p = data_.at(pos);
p->metrics(st);
ascent_ = std::max(ascent_, p->ascent());
MathAtom const * p = data_.at(pos);
p->metrics(st);
ascent_ = std::max(ascent_, p->ascent());
- for (int pos = 0; pos < data_.size(); ++pos) {
+ for (size_type pos = 0; pos < data_.size(); ++pos) {
MathAtom const * p = data_.at(pos);
p->draw(pain, x, y);
x += p->width();
MathAtom const * p = data_.at(pos);
p->draw(pain, x, y);
x += p->width();
-int MathXArray::pos2x(int targetpos) const
+int MathXArray::pos2x(size_type targetpos) const
{
int x = 0;
targetpos = std::min(targetpos, data_.size());
{
int x = 0;
targetpos = std::min(targetpos, data_.size());
- for (int pos = 0; pos < targetpos; ++pos)
+ for (size_type pos = 0; pos < targetpos; ++pos)
x += width(pos);
return x;
}
x += width(pos);
return x;
}
-int MathXArray::x2pos(int targetx) const
+MathArray::size_type MathXArray::x2pos(int targetx) const
- int pos = 0;
- int lastx = 0;
- int currx = 0;
+ size_type pos = 0;
+ int lastx = 0;
+ int currx = 0;
for ( ; currx < targetx && pos < data_.size(); ++pos) {
lastx = currx;
currx += width(pos);
for ( ; currx < targetx && pos < data_.size(); ++pos) {
lastx = currx;
currx += width(pos);
-int MathXArray::width(int pos) const
+int MathXArray::width(size_type pos) const
{
MathAtom const * t = data_.at(pos);
return t ? t->width() : 0;
{
MathAtom const * t = data_.at(pos);
return t ? t->width() : 0;
class MathXArray
{
public:
class MathXArray
{
public:
+ ///
+ typedef MathArray::size_type size_type;
+
///
int yo() const { return yo_; }
///
///
int yo() const { return yo_; }
///
- int pos2x(int pos) const;
+ int pos2x(size_type pos) const;
- int x2pos(int pos) const;
+ size_type x2pos(int pos) const;
- int width(int pos) const;
+ int width(size_type pos) const;
///
int ascent() const { return ascent_; }
///
int ascent() const { return ascent_; }