Returns the index of the first invalid character of the zone, or -1 if the zone is valid

@param sequence
@return
480753
public static int validateZone(CharSequence zone) {
		for(int i = 0; i < zone.length(); i++) {
			char c = zone.charAt(i);
			if (c == IPAddress.PREFIX_LEN_SEPARATOR) {
				return i;
			}
			if (c == IPv6Address.SEGMENT_SEPARATOR) {
				return i;
			}
		}
		return -1;
	}
755097
public String sequence(int hashCode) {
        if (hashCode <= 0)
            return null;

        int state = 0;

        // If the hash code is larger than the number of suffixes in the start state,
        // the hash code does not correspond to a sequence.
        if (hashCode > d_nSeqs)
            return null;

        StringBuilder wordBuilder = new StringBuilder();

        // Stop if we are in a state where we cannot add more characters.
        while (d_stateOffsets.get(state) != transitionsUpperBound(state)) {

            // Obtain the next transition, decreasing the hash code by the number of
            // preceding suffixes.
            int trans = d_transitionNSuffixes.binarySearch(d_stateOffsets.get(state), transitionsUpperBound(state), hashCode);
            if (trans >= 0)
                --trans;
            else
                trans = -trans - 2;

            hashCode -= d_transitionNSuffixes.get(trans);

            // Add the character on the given transition and move.
            wordBuilder.append(d_transitionChars[trans]);
            state = d_transitionTo.get(trans);

            // If we encounter a final state, decrease the hash code, since it represents a
            // suffix. If our hash code is reduced to zero, we have found the sequence.
            if (d_finalStates.get(state)) {
                --hashCode;

                if (hashCode == 0)
                    return wordBuilder.toString();
            }
        }

        // Bad luck, we cannot really get here!
        return null;
    }
1320756
public static String cleanup(String sequence) {
    String result = sequence.replaceAll("\\s", ""); // remove all white
    // space
    if (result.equals(result.toLowerCase())) {
      result = result.toUpperCase();
    }
    return result;
  }
508775
static int getIndex(CharSequence name) {
        Integer index = STATIC_INDEX_BY_NAME.get(name);
        if (index == null) {
            return -1;
        }
        return index;
    }
983788
public String getFormatedSequence(final int width) {
	if (sequence == null) {
		return "";
	}

	assert width >= 0 : "Wrong width parameter ";

	final StringBuilder sb = new StringBuilder(sequence);
	int nchunks = sequence.length() / width;
	// add up inserted new line chars
	nchunks = (nchunks + sequence.length()) / width;
	int nlineCharcounter = 0;
	for (int i = 1; i <= nchunks; i++) {
		final int insPos = width * i + nlineCharcounter;
		// to prevent inserting new line in the very end of a sequence then
		// it would have failed.
		// Also covers the case when the sequences shorter than width
		if (sb.length() <= insPos) {
		break;
		}
		sb.insert(insPos, "\n");
		nlineCharcounter++;
	}
	return sb.toString();
	}
628785
public static <S extends Sequence<C>, C extends Compound> int getGCGChecksum(S sequence) {
		String s = sequence.toString().toUpperCase();
		int count = 0, check = 0;
		for (int i = 0; i < s.length(); i++) {
			count++;
			check += count * s.charAt(i);
			if (count == 57) {
				count = 0;
			}
		}
		return check % 10000;
	}
419975
private ByteBuffer removeChar(Sequence sequenceObj)
	{

		byte[] sequenceByte = sequenceObj.getSequenceByte();
		int beginPosition = 0;
		int endPosition = (int) sequenceObj.getLength();
		if (sequenceByte[0] == 'n')
		{
			for (byte base : sequenceByte)
			{
				if ('n' == (char) base)
				{
					beginPosition++;
					beginDelSequenceStr+=(char)base;
				}
				else
				{
					break;
				}
			}
			
			if (beginPosition == endPosition)
			{
				return ByteBuffer.wrap(new byte[0]);
			}
		}
		if (sequenceByte[endPosition - 1] == 'n')
		{

			for (int i = endPosition - 1; i > 0; i--)
			{
				if ('n' == sequenceByte[i])
				{
					endPosition--;
				}
				else
				{
					break;
				}
			}
		}

		int length = (int) (endPosition - beginPosition);
		int offset = beginPosition;
		byte[] strippedSequence = new byte[length];
		System.arraycopy(sequenceObj.getSequenceByte(), offset, strippedSequence, 0, length);
		return ByteBuffer.wrap(strippedSequence, 0, strippedSequence.length);

	}
1147350
public int[] buildSuffixArray(CharSequence sequence) {
        /*
         * Allocate slightly more space, some suffix construction strategies need it and
         * we don't want to waste space for multiple symbol mappings.
         */

        this.input = new int[sequence.length() + SuffixArrays.MAX_EXTRA_TRAILING_SPACE];
        for (int i = sequence.length() - 1; i >= 0; i--) {
            input[i] = sequence.charAt(i);
        }

        final int start = 0;
        final int length = sequence.length();

        final ISymbolMapper mapper = new DensePositiveMapper(input, start, length);
        mapper.map(input, start, length);

        return delegate.buildSuffixArray(input, start, length);
    }
1077426
int nextIndexOf(CharSequence seq) {
        bufferUp();
        // doesn't handle scanning for surrogates
        char startChar = seq.charAt(0);
        for (int offset = bufPos; offset < bufLength; offset++) {
            // scan to first instance of startchar:
            if (startChar != charBuf[offset])
                while(++offset < bufLength && startChar != charBuf[offset]) { /* empty */ }
            int i = offset + 1;
            int last = i + seq.length()-1;
            if (offset < bufLength && last <= bufLength) {
                for (int j = 1; i < last && seq.charAt(j) == charBuf[i]; i++, j++) { /* empty */ }
                if (i == last) // found full sequence
                    return offset - bufPos;
            }
        }
        return -1;
    }
664605
public static int getBondCount(IChemSequence sequence) {
        int count = 0;
        for (int i = 0; i < sequence.getChemModelCount(); i++) {
            count += ChemModelManipulator.getBondCount(sequence.getChemModel(i));
        }
        return count;
    }
387776
private boolean containsSeq(String seq) {
        int state = 0;
        for (int i = 0; i < seq.length(); i++) {
            state = next(state, seq.charAt(i));

            if (state == -1)
                return false;
        }

        return d_finalStates.get(state);
    }
477546
public static int index(String string) {
        int length = string.length();
        for (int i = 0; i < length; i++) {
            if (getCorrespondingSymbol(string.charAt(i)) != ' ') {
                return i;
            }
        }
        return -1;
    }
1166040
public static int compareUtf16BE(Slice utf8Left, Slice utf8Right)
    {
        int leftLength = utf8Left.length();
        int rightLength = utf8Right.length();

        int offset = 0;
        while (offset < leftLength) {
            // if there are no more right code points, right is less
            if (offset >= rightLength) {
                return 1; // left.compare(right) > 0
            }

            int leftCodePoint = tryGetCodePointAt(utf8Left, offset);
            if (leftCodePoint < 0) {
                throw new InvalidUtf8Exception("Invalid UTF-8 sequence in utf8Left at " + offset);
            }

            int rightCodePoint = tryGetCodePointAt(utf8Right, offset);
            if (rightCodePoint < 0) {
                throw new InvalidUtf8Exception("Invalid UTF-8 sequence in utf8Right at " + offset);
            }

            int result = compareUtf16BE(leftCodePoint, rightCodePoint);
            if (result != 0) {
                return result;
            }

            // the code points are the same and non-canonical sequences are not allowed,
            // so we advance a single offset through both sequences
            offset += lengthOfCodePoint(leftCodePoint);
        }

        // there are no more left code points, so if there are more right code points,
        // left is less
        if (offset < rightLength) {
            return -1; // left.compare(right) < 0
        }

        return 0;
    }
960594
public static boolean containsIgnoreCase(CharSequence sequence, CharSequence subSequence) {
    // Calling length() is the null pointer check (so do it before we can exit early).
    int length = sequence.length();
    if (sequence == subSequence) {
      return true;
    }
    // if subSequence is longer than sequence, it is impossible for sequence to contain subSequence
    if (subSequence.length() > length) {
      return false;
    }
    return indexOfIgnoreCase(sequence, subSequence) > -1;
  }
186006
public Object retrieve(int sequence) {
        int index = toIndex(sequence);
        checkSequence(index, sequence);
        return ringItems[index];
    }
315566
public static int findNotIn(byte[] arra, int start, int limit,
                                byte[] charset) {

        int k = 0;

        for (; k < limit; k++) {
            for (int i = 0; i < charset.length; i++) {
                if (arra[k] == charset[i]) {
                    continue;
                }
            }

            return k;
        }

        return -1;
    }
1230215
public int firstIndexOf(CqlIdentifier id) {
    Integer index = byId.get(id);
    return (index == null) ? -1 : index;
  }