Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
struct Trie
{
Rune c;
Trie*[Rune] children;
bool isEntry;
bool value;
}
type trie_p
type(trie), pointer :: p => NULL()
end type trie_p
type trie
class(*), allocatable :: value
type(trie_p), dimension(:), allocatable :: nodes
end type trie
type Trie struct {
c rune
children map[rune]*Trie
isEntry bool
value V
}
data Trie v
= Branch Char (Map Char (Trie v))
| Leaf Char v
local function New(base,new)
return setmetatable(new,{__index=base})
end
local Trie={}
function Trie.New()
return New(Trie,{
children={},
value=nil
})
end
class Trie:
def __init__(self, prefix, value=None):
self.prefix = prefix
self.children = []
self.value = value
struct Trie {
val: String,
nodes: Vec<Trie>
}