|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.hankcs.hanlp.collection.trie.bintrie.BaseNode<V>
com.hankcs.hanlp.collection.trie.bintrie.BinTrie<V>
public class BinTrie<V>
首字直接分配内存,之后二分动态数组的Trie树,能够平衡时间和空间
| 嵌套类摘要 |
|---|
| 从类 com.hankcs.hanlp.collection.trie.bintrie.BaseNode 继承的嵌套类/接口 |
|---|
BaseNode.Status, BaseNode.TrieEntry |
| 字段摘要 |
|---|
| 从类 com.hankcs.hanlp.collection.trie.bintrie.BaseNode 继承的字段 |
|---|
c, child, status, value |
| 构造方法摘要 | |
|---|---|
BinTrie()
|
|
| 方法摘要 | |
|---|---|
protected boolean |
addChild(BaseNode node)
添加子节点 |
int |
build(TreeMap<String,V> keyValueMap)
|
LinkedList<Map.Entry<String,V>> |
commonPrefixSearchWithValue(char[] chars,
int begin)
前缀查询,通过字符数组来表示字符串可以优化运行速度 |
LinkedList<Map.Entry<String,V>> |
commonPrefixSearchWithValue(String key)
前缀查询,包含值 |
boolean |
containsKey(String key)
|
Set<Map.Entry<String,V>> |
entrySet()
获取键值对集合 |
V |
get(char[] key)
|
V |
get(String key)
|
protected char |
getChar()
|
BaseNode |
getChild(char c)
获取子节点 |
V[] |
getValueArray(V[] a)
|
Set<String> |
keySet()
键集合 |
boolean |
load(ByteArray byteArray,
_ValueArray valueArray)
|
boolean |
load(ByteArray byteArray,
V[] value)
|
boolean |
load(String path)
只加载值,此时相当于一个set |
boolean |
load(String path,
V[] value)
从磁盘加载二分数组树 |
_ValueArray |
newValueArray()
|
Set<Map.Entry<String,V>> |
prefixSearch(String key)
前缀查询 |
void |
put(char[] key,
V value)
|
void |
put(String key,
V value)
插入一个词 |
void |
remove(String key)
删除一个词 |
boolean |
save(DataOutputStream out)
保存到二进制输出流 |
boolean |
save(String path)
|
void |
set(String key,
V value)
设置键值对,当键不存在的时候会自动插入 |
int |
size()
|
| 从类 com.hankcs.hanlp.collection.trie.bintrie.BaseNode 继承的方法 |
|---|
compareTo, compareTo, getStatus, getValue, hasChild, setValue, toString, transition, walk, walkToLoad, walkToSave |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 构造方法详细信息 |
|---|
public BinTrie()
| 方法详细信息 |
|---|
public void put(String key,
V value)
key - value -
public void put(char[] key,
V value)
public void set(String key,
V value)
key - value - public void remove(String key)
key - public boolean containsKey(String key)
ITrie<V> 中的 containsKeypublic V get(String key)
ITrie<V> 中的 getpublic V get(char[] key)
ITrie<V> 中的 getpublic V[] getValueArray(V[] a)
ITrie<V> 中的 getValueArraypublic Set<Map.Entry<String,V>> entrySet()
public Set<String> keySet()
public Set<Map.Entry<String,V>> prefixSearch(String key)
key - 查询串
public LinkedList<Map.Entry<String,V>> commonPrefixSearchWithValue(String key)
key - 键
public LinkedList<Map.Entry<String,V>> commonPrefixSearchWithValue(char[] chars,
int begin)
chars - 字符串的字符数组begin - 开始的下标
protected boolean addChild(BaseNode node)
BaseNode 复制的描述
BaseNode<V> 中的 addChildpublic int size()
ITrie<V> 中的 sizeprotected char getChar()
BaseNode<V> 中的 getCharpublic BaseNode getChild(char c)
BaseNode 复制的描述
BaseNode<V> 中的 getChildc - 子节点的char
public boolean save(String path)
public int build(TreeMap<String,V> keyValueMap)
ITrie<V> 中的 buildpublic boolean save(DataOutputStream out)
ITrie<V> 中的 saveout -
public boolean load(String path,
V[] value)
path - 路径value - 额外提供的值数组,按照值的字典序。(之所以要求提供它,是因为泛型的保存不归树管理)
public boolean load(String path)
path -
public boolean load(ByteArray byteArray,
_ValueArray valueArray)
public boolean load(ByteArray byteArray,
V[] value)
ITrie<V> 中的 loadpublic _ValueArray newValueArray()
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||