TST.insert
You're seeing just the function
insert
, go back to TST module for more information.
Specs
insert( %TST{ item: term(), left: term(), middle: term(), right: term(), value: term() }, String.t(), any() ) :: %TST{ item: term(), left: term(), middle: term(), right: term(), value: term() }
Insert a key-value pair into a TST. It is acceptable to pass nil as the first argument - a new TST will then be created.
Parameters
- tst: A Ternary Search Trie map or nil (no tree yet created)
- key: A String key in which to associate a value with
- value: The value that you want to have stored. Can be of any type
Examples
iex> TST.new() |> TST.insert("key", "value")
%TST{
item: nil,
left: nil,
middle: %TST{
item: nil,
left: nil,
middle: %TST{item: "value", left: nil, middle: nil, right: nil, value: "y"},
right: nil,
value: "e"
},
right: nil,
value: "k"
}