tyre / red_black_tree

Red-black tree implementation for Elixir.
MIT License
38 stars 14 forks source link

Dict is deprecated and Access is no longer a Protocol #15

Open suprafly opened 6 years ago

suprafly commented 6 years ago

Access is a Behaviour, so this library needs to be updated to support it. Try,

@behaviour Access
def get(tree, key) do
  RedBlackTree.get(tree, key)
end

def get_and_update(tree, key, fun) do
  {get, update} = fun.(RedBlackTree.get(tree, key))
  {get, RedBlackTree.insert(tree, key, update)}
end

Elixir uses Map's now, not Dict's:

warning: use Dict is deprecated, use the Map module for working with maps or the Keyword module for working with keyword lists
  lib/red_black_tree.ex:16

also,

warning: function slice/1 required by protocol Enumerable is not implemented (in module Enumerable.RedBlackTree)
  lib/red_black_tree.ex:627
suprafly commented 6 years ago

Digging deeper, this issue might be more that the version available through Hex does not match the latest in Github.