return getElementCount() - 1;
lastIndex = index; } return index;
    public int getElementIndex(int offset)    {      // If offset is less than the start offset of our first child,      // return 0      if (offset < getStartOffset())        return 0;            // XXX: There is surely a better algorithm      // as beginning from first element each time.      for (int index = 0; index < children.length - 1; ++index)        {          Element elem = children[index];          if ((elem.getStartOffset() <= offset)               && (offset < elem.getEndOffset()))            return index;          // If the next element's start offset is greater than offset          // then we have to return the closest Element, since no Elements          // will contain the offset          if (children[index + 1].getStartOffset() > offset)            {              if ((offset - elem.getEndOffset()) > (children[index + 1].getStartOffset() - offset))                return index + 1;              else                return index;            }        }      // If offset is greater than the index of the last element, return      // the index of the last element.      return getElementCount() - 1;    }