gpt4 book ai didi

c - Ghashtable 存储双

转载 作者:太空宇宙 更新时间:2023-11-03 23:34:50 26 4
gpt4 key购买 nike

你好,考虑到没有 gdouble_to_pointer 方法,我想知道是否可以将 double 存储到 ghashtable 中。我正在学习 IBM 在线找到的教程 http://www.ibm.com/developerworks/linux/tutorials/l-glib/section5.html ,但我似乎无法找到一种方法来使用 int 作为键并使用 double 作为存储的值。任何帮助都会非常感谢!

最佳答案

如果要使用 int 作为键,则应在创建 GHashTable 时使用 g_int_hash() 和 g_int_equal()。

就对值使用 double 而言……你不能。问题是你不能保证 sizeof (void *) >= sizeof (double),所以你不能使用像 GINT_TO_POINTER() 这样的技巧

关于c - Ghashtable 存储双,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6682731/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com