change the structure of codes, imitating rb_tree and map in STL