mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Bindings: Add a method for iterating in lexicographically sorted order
This commit is contained in:
parent
b1f001538e
commit
54801ed6ad
4 changed files with 28 additions and 28 deletions
|
@ -75,6 +75,19 @@ public:
|
|||
|
||||
size_t capacity() { return capacity_; }
|
||||
|
||||
/* Returns the attributes in lexicographically sorted order. */
|
||||
std::vector<const Attr *> lexicographicOrder() const
|
||||
{
|
||||
std::vector<const Attr *> res;
|
||||
res.reserve(size_);
|
||||
for (size_t n = 0; n < size_; n++)
|
||||
res.emplace_back(&attrs[n]);
|
||||
std::sort(res.begin(), res.end(), [](const Attr * a, const Attr * b) {
|
||||
return (string) a->name < (string) b->name;
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
friend class EvalState;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue