use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.
the class BinTrie method load.
/**
* 从磁盘加载二分数组树
*
* @param path 路径
* @param value 额外提供的值数组,按照值的字典序。(之所以要求提供它,是因为泛型的保存不归树管理)
* @return 是否成功
*/
public boolean load(String path, V[] value) {
byte[] bytes = IOUtil.readBytes(path);
if (bytes == null)
return false;
_ValueArray valueArray = new _ValueArray(value);
ByteArray byteArray = new ByteArray(bytes);
for (int i = 0; i < child.length; ++i) {
int flag = byteArray.nextInt();
if (flag == 1) {
child[i] = new Node<V>();
child[i].walkToLoad(byteArray, valueArray);
}
}
size = value.length;
return true;
}
Aggregations