Update covered? method to also check include?
What does this MR do and why?
follow up from !166774 (comment 2141225570)
To make the new TrieNode
class more useful outside of search, the covered?
method will also return true if the value is alrea≈dy contained in the data structure
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
N/A
How to set up and validate locally
- open rails console
- create an instance of
Namespaces::Traversal::TrieNode
- test the
covered?
method
elastic_namespace_ancestry = [
"6543-",
"9970-",
"349181-",
"349181-2370953-",
"3326537-3326540-3839694-",
"9970-3887963-3887968-",
"9970-3952433-",
"4347861-",
"5255972-",
"5723700-",
"9970-6185122-",
"6981270-",
"6981270-6981274-",
"3326537-3326540-7081322-",
"7117794-",
"7977151-",
"7977151-8334378-",
"10545889-",
"11341738-",
"12319978-",
"6543-12482574-12772664-",
"14854200-15979185-",
"14854200-16061542-",
"14854200-16061973-",
"58787695-",
"60717473-",
"9970-6185122-67749417-",
"70922517-",
"70922709-",
"70922747-",
"70922517-73697813-",
"79487724-",
"79329146-79490006-",
"9970-6185122-79935949-",
"9970-6185122-82866933-",
"79329146-79490006-83376676-",
"9970-6185122-89234823-",
"79329146-89566663-",
"9970-6185122-91022131-"
]
traversal_ids = elastic_namespace_ancestry.map { |x| x.split("-").map(&:to_i) }
trie = ::Namespaces::Traversal::TrieNode.build(traversal_ids)
[13] pry(main)> trie.covered?([9970])
=> true
[14] pry(main)> trie.covered?([9970, 123, 345])
=> true
[15] pry(main)> trie.covered?([3326537])
=> false
Edited by Terri Chu