当前位置: 首页>>代码示例>>Java>>正文


Java GetChars类代码示例

本文整理汇总了Java中android.text.GetChars的典型用法代码示例。如果您正苦于以下问题:Java GetChars类的具体用法?Java GetChars怎么用?Java GetChars使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GetChars类属于android.text包,在下文中一共展示了GetChars类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getChars

import android.text.GetChars; //导入依赖的package包/类
public static void getChars(CharSequence s, int start, int end,
                            char[] dest, int destoff) {
    Class c = s.getClass();

    if (c == String.class)
        ((String) s).getChars(start, end, dest, destoff);
    else if (c == StringBuffer.class)
        ((StringBuffer) s).getChars(start, end, dest, destoff);
    else if (c == StringBuilder.class)
        ((StringBuilder) s).getChars(start, end, dest, destoff);
    else if (s instanceof GetChars)
        ((GetChars) s).getChars(start, end, dest, destoff);
    else {
        for (int i = start; i < end; i++)
            dest[destoff++] = s.charAt(i);
    }
}
 
开发者ID:jiro-aqua,项目名称:JotaTextEditor,代码行数:18,代码来源:TextUtils.java

示例2: copyString

import android.text.GetChars; //导入依赖的package包/类
public static String copyString(CharSequence charSequence) {
    int length = charSequence.length();
    char[] chars = new char[length];

    if (charSequence instanceof GetChars) {
        ((GetChars)charSequence).getChars(0, length, chars, 0);
    } else {
        for (int i = 0; i < length; i++) {
            chars[i] = charSequence.charAt(i);
        }
    }

    return new String(chars);
}
 
开发者ID:mta452,项目名称:Tehreer-Android,代码行数:15,代码来源:StringUtils.java

示例3: indexOf

import android.text.GetChars; //导入依赖的package包/类
public static int indexOf(CharSequence s, char ch, int start, int end) {
    Class c = s.getClass();

    if (s instanceof GetChars || c == StringBuffer.class ||
        c == StringBuilder.class || c == String.class) {
        final int INDEX_INCREMENT = 500;
        char[] temp = obtain(INDEX_INCREMENT);

        while (start < end) {
            int segend = start + INDEX_INCREMENT;
            if (segend > end)
                segend = end;

            getChars(s, start, segend, temp, 0);

            int count = segend - start;
            for (int i = 0; i < count; i++) {
                if (temp[i] == ch) {
                    recycle(temp);
                    return i + start;
                }
            }

            start = segend;
        }

        recycle(temp);
        return -1;
    }

    for (int i = start; i < end; i++)
        if (s.charAt(i) == ch)
            return i;

    return -1;
}
 
开发者ID:jiro-aqua,项目名称:JotaTextEditor,代码行数:37,代码来源:TextUtils.java

示例4: append

import android.text.GetChars; //导入依赖的package包/类
public final void append(@NonNull GetChars s) {
    int length = s.length();
    s.getChars(0, length, value, count);
    this.count += length;
}
 
开发者ID:chdir,项目名称:aria2-android,代码行数:6,代码来源:AppendableStringBuilder.java

示例5: lastIndexOf

import android.text.GetChars; //导入依赖的package包/类
public static int lastIndexOf(CharSequence s, char ch,
                              int start, int last) {
    if (last < 0)
        return -1;
    if (last >= s.length())
        last = s.length() - 1;

    int end = last + 1;

    Class c = s.getClass();

    if (s instanceof GetChars || c == StringBuffer.class ||
        c == StringBuilder.class || c == String.class) {
        final int INDEX_INCREMENT = 500;
        char[] temp = obtain(INDEX_INCREMENT);

        while (start < end) {
            int segstart = end - INDEX_INCREMENT;
            if (segstart < start)
                segstart = start;

            getChars(s, segstart, end, temp, 0);

            int count = end - segstart;
            for (int i = count - 1; i >= 0; i--) {
                if (temp[i] == ch) {
                    recycle(temp);
                    return i + segstart;
                }
            }

            end = segstart;
        }

        recycle(temp);
        return -1;
    }

    for (int i = end - 1; i >= start; i--)
        if (s.charAt(i) == ch)
            return i;

    return -1;
}
 
开发者ID:jiro-aqua,项目名称:JotaTextEditor,代码行数:45,代码来源:TextUtils.java


注:本文中的android.text.GetChars类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。