Algorithm 如何设计一个混合了哈希表和堆的数据结构

Algorithm 如何设计一个混合了哈希表和堆的数据结构,algorithm,heap,hashtable,Algorithm,Heap,Hashtable,我的问题如下: 给定一个三元组列表,它们存储在一个名为hash_heap的数据结构中(我不确定名称,只是说它应该是hashtable和heap的混合体)。我希望数据结构提供以下方法 index_by_first_col(key) // the method could help find the a triple stored in it by matching the first column. It expects the searching is running at constant t

我的问题如下:

给定一个三元组列表,它们存储在一个名为hash_heap的数据结构中(我不确定名称,只是说它应该是hashtable和heap的混合体)。我希望数据结构提供以下方法

index_by_first_col(key) // the method could help find the a triple stored in it by matching the first column. It expects the searching is running at constant time
get_min_by_third_col() // the method get the minimum triple sort according to the third column, it is also expects the method is running at constant time.
insert_new_elt(triple) // add new trip, running at constant time
有可能实现这样的数据结构吗?我知道hashtable可以支持第一种方法,heap可以支持第二种和第三种方法,但我不知道如何将它们混合在一起。有什么想法吗


谢谢

有一个非常简单的数据结构,可以满足您所述的要求

使用一个哈希表(在第一列上键入),另外存储一个指向最小元素的指针(在第三列上)。然后,
index\u by\u first\u col
是哈希表查找,
get\u min\u by\u third\u col
是指针解引用,
insert\u new\u elt
是哈希表插入和比较,以确定是否需要更新最小指针


请注意,这会导致O(n)删除(最小值),但您没有说明任何删除要求。

我想以前有人问过这个问题:请注意,堆不支持您的第三种方法,在堆中插入是O(log n)。实际上,我需要删除操作,更准确地描述“get_min_by_third_col”应该是pop_min_by_third_col