Collections.binarySearch(Java)中的下划线(389;)存在问题
问题: 我正在为此使用源代码。这是 我试过这个:Collections.binarySearch(Java)中的下划线(389;)存在问题,java,list,collections,binary-search,Java,List,Collections,Binary Search,问题: 我正在为此使用源代码。这是 我试过这个: --following with another section of sorted words-- words.add("count"); words.add("cvs"); words.add("dce"); words.add("depth"); --following with another section of sorted words-- 而且它工作得很好。但是,当我使用此选项时: --just a section of sor
--following with another section of sorted words--
words.add("count");
words.add("cvs");
words.add("dce");
words.add("depth");
--following with another section of sorted words--
而且它工作得很好。但是,当我使用此选项时:
--just a section of sorted words--
words.add("count");
words.add("cvs");
words.add("dce_iface");
words.add("dce_opnum");
words.add("dce_stub_data");
words.add("depth");
--following with another section of sorted words--
当我键入dce
时,它确实会显示dce\iface
,但当我键入
时,然后在o
或s
之后,它会显示类似于dce\u offset
的其他内容,其中偏移量来自单词。添加(“fragoffset”)代码>列表中的某个位置
我能做些什么来解决这个问题?提前谢谢。可能是因为代码中有以下几行:
for (w = pos; w >= 0; w--) {
if (! Character.isLetter(content.charAt(w))) {
break;
}
}
\u
不是字母字符,因此它将其视为空格。您可以尝试将条件更改为:
char c = content.charAt(w);
if (! (Character.isLetter(c) || c == '_')) {
这可能是因为代码中有以下几行代码:
for (w = pos; w >= 0; w--) {
if (! Character.isLetter(content.charAt(w))) {
break;
}
}
\u
不是字母字符,因此它将其视为空格。您可以尝试将条件更改为:
char c = content.charAt(w);
if (! (Character.isLetter(c) || c == '_')) {
我想你必须在这里加下划线作为“字母”
我想你必须在这里加下划线作为“字母”
它与insertUpdate()中的本节有关:
具体来说,Character.isleter()
为下划线字符返回false。这意味着该单词在下划线位置之后开始
要解决这个问题,您需要修改if
语句,以允许在单词中使用任何非字母字符。您可以显式地检查“\u”或使用character.isWhiteSpace()
来包括所有不是空格、制表符或换行符的字符。这与insertUpdate()
中的此部分有关:
具体来说,Character.isleter()
为下划线字符返回false。这意味着该单词在下划线位置之后开始
要解决这个问题,您需要修改if
语句,以允许在单词中使用任何非字母字符。您可以显式地检查“\uu”或使用character.isWhiteSpace()
来包括所有不是空格、制表符或换行符的字符。OT--Hmm奇怪的是,我的Chrome突然没有显示添加注释的文本区域。让我困惑了一会儿@罗宾斯特——啊,我明白了。谢谢OT--嗯,奇怪的是,我的Chrome浏览器突然没有显示添加评论的文本区域。让我困惑了一会儿@罗宾斯特——啊,我明白了。谢谢@科林:+1表示详细解释。@科林:+1表示详细解释。