Class KeyMappingTrie
java.lang.Object
org.aesh.readline.action.KeyMappingTrie
A trie-based data structure for efficient key sequence matching.
Provides O(m) lookup complexity where m is the length of the input sequence,
compared to O(n*m) for linear search where n is the number of mappings.
- Author:
- Ståle W. Pedersen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classResult of a trie match operation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidBuilds the trie from the given key mappings.voidclear()Clears all mappings from the trie.match(int[] buffer) Matches the input buffer against the trie.matchSingleByte(int code) Fast path for single-byte matching.
-
Constructor Details
-
KeyMappingTrie
public KeyMappingTrie()
-
-
Method Details
-
build
Builds the trie from the given key mappings. This clears any existing mappings and rebuilds the trie.- Parameters:
mappings- the array of KeyAction mappings to index
-
clear
public void clear()Clears all mappings from the trie. -
matchSingleByte
Fast path for single-byte matching.- Parameters:
code- the single byte code point- Returns:
- the match result
-
match
Matches the input buffer against the trie. Returns the longest matching KeyAction and whether the buffer is a prefix of longer sequences.- Parameters:
buffer- the input code points to match- Returns:
- the match result containing the action and prefix information
-