因为我已经在刚刚学会在我的其他问题,我可以用为一个结构,其中有一个composite_key和整数的std::vector。现在的问题是:我可以用这张某种方式与hashed_indecies工作

下面类似一个例子来此内容

struct unique_property
{
  //the pair of int and std::vector<int> shall be unique
  int my_int;
  std::vector<int>  my_vec;
};

typedef multi_index_container<
  unique_property,
  indexed_by<
    hashed_unique< // indexed by my_int and every entry of my_vec
      composite_key<
        street_entry,
        member<unique_property,int,&unique_property::my_int>,
        member<unique_property,std::vector<int>,&unique_property::my_vec>
      >
    >,
    random_access< >
  >
> property_locator;

问题是(当然),一个std::vector<int>是没有合适的散列键。我可以把一个优雅的包装代码(或类似的东西),以从my_vec,以及每个项目的哈希键?

有帮助吗?

其他提示

如果你想向量是哈希的,你可以只写在hash<vector<int> >一个namespace std功能,使得它不过凑请你(提示:你也许可以只用散列在某些应用中前几个元素逃脱)。这应该使std::hash_set<vector<int> >的工作,我觉得你更复杂的容器为好。

scroll top