``[]
嗨,我遇到了与操作员[] MAP中插入值的迭代顺序有关的问题。
代码为a github程序在第265行中: many_async_rules [rstVal] .insert(sync_level);
地图的定义是std :: map< rt; rt; rt; rtlil :: sigspec,std :: set< rt; rtlil :: rt; rt; rt; rt; rt; rt; rt; rt; rtlil :: syncrule*> 。
通过测试案例并猜测其含义,该行应将rstVal
插入Manus_async_rules
的第一个迭代器插槽中
但是,在我的计算机中,它实际上将rstval
放入了最后一个。
因此,我想询问这是否在std :: Map
中是否正常?
以下是我的计算机的一些系统信息:
[shore@shore-82b6 yosys]$ gcc --version
gcc (GCC) 11.2.0
Copyright © 2021 Free Software Foundation, Inc.
[shore@shore-82b6 yosys]$ cat /etc/lsb-release
DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=21.2.6
DISTRIB_CODENAME=Qonos
DISTRIB_DESCRIPTION="Manjaro Linux"
需要的任何额外信息,请发表评论。
Hi I've met a problem relating to iterator order of inserted values in std::map by operator [].
The code is a github program in line 265: many_async_rules[rstval].insert(sync_level);
The definition of the map is std::map<RTLIL::SigSpec, std::set<RTLIL::SyncRule*>> many_async_rules;
By testing cases and guessing its meaning, this line should insert the rstval
into the first iterator slot of many_async_rules
.
However, in my machine it actually put the rstval
into the last of it.
Thus I would like to ask if this is normal in std::map
??
The following is some system info of my computer:
[shore@shore-82b6 yosys]$ gcc --version
gcc (GCC) 11.2.0
Copyright © 2021 Free Software Foundation, Inc.
[shore@shore-82b6 yosys]$ cat /etc/lsb-release
DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=21.2.6
DISTRIB_CODENAME=Qonos
DISTRIB_DESCRIPTION="Manjaro Linux"
Any extra info needed, please leave comment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
std :: Map
的元素按建立的密钥进行存储,比较
predicate(默认情况下,std :: Silly
std :: sily < /代码>)。如果
rstVal
是根据谓词的最小关键,则将是第一个元素。如果rstVal
是根据谓词的最大键,则将是最后一个元素。如果键是指针,而谓词为
std :: Less
,并且指示器是数组的元素,则该顺序与该数组中指向元素的顺序相同。但是,如果指针不是数组元素,则它们的相对顺序是未指定的。Elements of
std::map
are stored in order of the key established by theCompare
predicate that was provided to the map (by default,std::less
). Ifrstval
is the least key according to the predicate, then it will be the first element. Ifrstval
is the greatest key according to the predicate, then it will be the last element.If the key is a pointer, and the predicate is
std::less
, and if the pointers are to elements of an array, then the order is the same as the order of the pointed elements in that array. But if the pointers are not to elements of an array, then their relative order is unspecified.