According MQTT topic standard design topic tree. topic format is the MQTT topic standard. Support common and wildcard search.
TopicTree<String> topicTree = new TopicTree<>(size);
//save "fate/stay/night" topic, data is "saber","caster"
topic.saveTopic("fate/stay/night","saber");
topic.saveTopic("fate/stay/night","caster");
if your topic is not carrying wildcards it will find the current topic and wildcard topic.if topic carries wildcards only find common topic.
//not wildcard search
List<String> commSearch = topicTree.search("fate/stay/night");
//wildcard search
List<String> wildCardSearch = topicTree.search("fate/#");
topicTree.remove("fate/stay/night")
topicTree.remove("fate/stay/night",v->{
v.remove("caster")
})