正則表達式樹
public class RegexTrie
extends Object
java.lang.Object |
↳ | com.android.tradefed.util.RegexTrie<V> |
RegexTrie 是一個 trie,其中每個存儲密鑰段是正則表達式ERROR(/Pattern)
。因此,全存儲key 是一個List<Pattern>
而不是List<String>
就像在標準的 trie 中一樣。請注意, retrieve(String)
方法將與Pattern
進行逐點匹配,而不是像標準 trie 中那樣檢查逐點相等性。因此,它可能對大型數據集表現不佳。
也可以在
Pattern
序列中使用
null
條目作為通配符。如果遇到
null
,序列中的所有後續條目都將被忽略。當檢索代碼遇到
null
Pattern
時,它將首先等待查看是否有更具體的條目與序列匹配。如果匹配,則更具體的條目將繼續進行,即使它隨後無法匹配。
如果沒有更具體的條目匹配,通配符匹配會將所有剩餘的
String
添加到捕獲列表(如果啟用)並返回與通配符關聯的值。
通配符功能的簡短示例:
List<List<String>> captures = new LinkedList<List<String>>();
RegexTrie<Integer> trie = new RegexTrie<Integer>();
trie.put(2, "a", null);
trie.put(4, "a", "b");
trie.retrieve(captures, "a", "c", "e");
// returns 2. captures is now [[], ["c"], ["e"]]
trie.retrieve(captures, "a", "b");
// returns 4. captures is now [[], []]
trie.retrieve(captures, "a", "b", "c");
// returns null. captures is now [[], []]
概括
公共構造函數
正則表達式樹
public RegexTrie ()
公共方法
放
public V put (V value,
Pattern... patterns)
向特里添加一個條目。
到字符串
public String toString ()