add rb tree and template for ideal hash