This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 基于Aho–Corasick算法的字典树实现,用于文本前缀快速查找 | |
* <p> | |
* ref: https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm | |
* <p> | |
**/ | |
public class AhoCorasickTrieTree { | |
private AhoCorasickTrieNode root = new AhoCorasickTrieNode(); // 根节点 | |
private boolean finished = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedList; | |
import org.springframework.util.Assert; | |
/** | |
* Interval Tree base on Red-Black Tree. It allows one to check if a interval overlap with any given intervals. | |
* 基于红黑树的间隔树结构,用于计算线段之间是否重叠 | |
* | |
* <p> | |
* 红黑树插入节点规则: | |
* Rule 1: 每个节点不是红色就是黑色. |