|
Macaulay2 Engine
|
MonomialSetFixedSize / MonomialSetVarSize / MonomialCollection* / MonomialMemorySpace — monomial-interning helpers. More...
#include "memtailor.h"#include <unordered_set>#include <unordered_map>#include <utility>#include <cassert>Go to the source code of this file.
Classes | |
| class | MonomialMemorySpace |
| Bump-pointer arena for monomial storage, backed by a memt::Arena. More... | |
| class | MonomialHashAndEqFixedSize |
| Combined hash + equality functor for fixed-size monomials, plugged into the std::unordered_set inside MonomialSetFixedSize. More... | |
| class | MonomialHashAndEqVarSize |
| Combined hash + equality functor for variable-size monomials, plugged into the std::unordered_set inside MonomialSetVarSize. More... | |
| class | MonomialSetFixedSize |
| class | MonomialSetVarSize |
| Hash set of interned variable-size monomials — the variable-length counterpart of MonomialSetFixedSize. More... | |
| class | MonomialCollectionFixedSize |
| Interning collection that pairs a MonomialSetFixedSize with its own MonomialMemorySpace to own monomial storage. More... | |
| class | MonomialCollectionVarSize |
| Variable-size counterpart of MonomialCollectionFixedSize: pairs a MonomialSetVarSize with its own MonomialMemorySpace. More... | |
MonomialSetFixedSize / MonomialSetVarSize / MonomialCollection* / MonomialMemorySpace — monomial-interning helpers.
Declares a five-class kit for interning monomials stored as contiguous int sequences. MonomialMemorySpace wraps a memt::Arena (memtailor) and hands out bump-pointer ranges via alloc(int size); allocations can be popped LIFO (popLastAlloc) or shrunk (shrinkLastAlloc), and the entire arena is freed in one shot at destruction. The Set variants — MonomialSetFixedSize (constructor takes the int size, not a <NWords> template parameter) and MonomialSetVarSize (treats *m as a length prefix so the monomial spans [m, m + *m)) — wrap a std::unordered_set<const int*, ...> and do no allocation themselves; the caller owns the storage. The Collection variants (MonomialCollectionFixedSize / MonomialCollectionVarSize) compose a Set with their own MonomialMemorySpace and implement the intern-or-pop pattern (findOrInsert copies the monomial into the arena, looks it up, and pops the allocation if a duplicate is already present).
The included MonomialHashAndEqFixedSize / MonomialHashAndEqVarSize functors implement equality correctly via std::equal, but their operator() for hashing is currently a // TODO: do something good here. stub that returns 0 — so the underlying std::unordered_set degenerates to a single bucket and comparisons fall through to the equality functor. This matches the comment in monomial-collection.hpp ("improve the hash function"); both files are mid-refactor scaffolding. The only active consumer in the engine is schreyer-resolution/res-f4.hpp, which holds a MonomialMemorySpace mMonomSpace2 (the arena alone — it does not use the Set / Collection classes here).
Definition in file monomial-sets.hpp.