mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 06:03:23 +00:00
Added dict/pool.sort()
This commit is contained in:
parent
1cb4c925d0
commit
43951099cf
7 changed files with 80 additions and 50 deletions
|
@ -457,6 +457,13 @@ public:
|
|||
return entries[i].udata.second;
|
||||
}
|
||||
|
||||
template<typename Compare = std::less<K>>
|
||||
void sort(Compare comp = Compare())
|
||||
{
|
||||
std::sort(entries.begin(), entries.end(), [comp](const entry_t &a, const entry_t &b){ return comp(b.udata.first, a.udata.first); });
|
||||
do_rehash();
|
||||
}
|
||||
|
||||
void swap(dict &other)
|
||||
{
|
||||
hashtable.swap(other.hashtable);
|
||||
|
@ -760,6 +767,13 @@ public:
|
|||
return i >= 0;
|
||||
}
|
||||
|
||||
template<typename Compare = std::less<K>>
|
||||
void sort(Compare comp = Compare())
|
||||
{
|
||||
std::sort(entries.begin(), entries.end(), [comp](const entry_t &a, const entry_t &b){ return comp(b.udata, a.udata); });
|
||||
do_rehash();
|
||||
}
|
||||
|
||||
void swap(pool &other)
|
||||
{
|
||||
hashtable.swap(other.hashtable);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue