OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
NameIndex.hpp File Reference

O(1) name-to-index lookup for SWMM objects. More...

#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>
#include <stdexcept>
#include <optional>
Include dependency graph for NameIndex.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  openswmm::NameIndex
 Bidirectional name↔index registry for SWMM objects. More...
 

Namespaces

namespace  openswmm
 

Detailed Description

O(1) name-to-index lookup for SWMM objects.

Wraps an unordered_map<string,int> to provide fast lookup of object indices by name. Used by SimulationContext for nodes, links, subcatchments, rain gages, tables, pollutants, and user flags.

Why a separate class?

The legacy SWMM engine uses project_findObject() in src/solver/project.c, which does a linear scan through the object name table. For models with hundreds of conduits this becomes noticeable during input parsing.

NameIndex replaces that with a hash map so every lookup is O(1).

See also
Legacy reference: src/solver/project.c — project_findObject()
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n MIT License