例子:
String wholeString =
"Typical models for star formation assume that every type of galaxy produces stars"
我想将拆分后的字符串及其以下 (+1) 字符串存储在树图中: with windowSize = 4
(predefined):
Typi
,ypic
-> 放入 TreeMap
ypic
,pica
-> 放入 TreeMap
因为windowSize = 2
它看起来像这样:
Ty
, yp
-> TreeMap
等等。
到目前为止我的代码:
Map<String, String> generateMap = new TreeMap<String, String>();
for (int i = 0; i < wholeString.length(); i++) {
generateMap
.put((wholeString.substring((i),
Math.min((i + windowSize), wholeString.length()))),
(wholeString.substring(
(i + 1),
(Math.min((i + windowSize),
wholeString.length())))));
}
如果我 sysprint 它,我会得到这个:
{ Augen=Augen, Außen=Außen, Innen=Innen, Jauch=Jauch,
等等