コード例 #1
0
 /**
  * Returns the index within this text of the first occurrence of the specified character, starting
  * the search at the specified index.
  *
  * @param c the character to search for.
  * @param fromIndex the index to start the search from.
  * @return the index of the first occurrence of the character in this text that is greater than or
  *     equal to <code>fromIndex</code>, or <code>-1</code> if the character does not occur.
  */
 public int indexOf(char c, int fromIndex) {
   if (_data != null) { // Primitive.
     for (int i = Math.max(fromIndex, 0); i < _count; i++) {
       if (_data[i] == c) return i;
     }
     return -1;
   } else { // Composite.
     final int cesure = _head._count;
     if (fromIndex < cesure) {
       final int headIndex = _head.indexOf(c, fromIndex);
       if (headIndex >= 0) return headIndex; // Found in head.
     }
     final int tailIndex = _tail.indexOf(c, fromIndex - cesure);
     return (tailIndex >= 0) ? tailIndex + cesure : -1;
   }
 }