added templates(based on rbtree implementation)