Bidirectional name↔index registry for SWMM objects.
More...
#include <NameIndex.hpp>
|
| | NameIndex ()=default |
| |
| int | add (const std::string &name) |
| | Add a new name and assign the next sequential index.
|
| |
| int | find (std::string_view name) const noexcept |
| | Look up the index for a name.
|
| |
| std::optional< int > | try_find (std::string_view name) const noexcept |
| | Look up the index, returning std::optional.
|
| |
| const std::string & | name_of (int idx) const |
| | Return the name for a given index.
|
| |
| int | size () const noexcept |
| | Number of registered names.
|
| |
| bool | empty () const noexcept |
| | True if no names are registered.
|
| |
| void | reserve (std::size_t n) |
| | Pre-allocate for a known count (avoids rehash during input).
|
| |
| void | clear () noexcept |
| | Remove all entries.
|
| |
| const std::vector< std::string > & | names () const noexcept |
| | Read-only access to the ordered name list.
|
| |
Bidirectional name↔index registry for SWMM objects.
Maintains both a hash map (name→index) and a vector (index→name) so that either direction of lookup is O(1).
◆ NameIndex()
| openswmm::NameIndex::NameIndex |
( |
| ) |
|
|
default |
◆ add()
| int openswmm::NameIndex::add |
( |
const std::string & |
name | ) |
|
|
inline |
Add a new name and assign the next sequential index.
- Parameters
-
| name | Object name (stored as-is; case sensitivity is caller's responsibility). |
- Returns
- Assigned index (== size() before this call).
- Exceptions
-
| std::invalid_argument | if name is already registered. |
◆ clear()
| void openswmm::NameIndex::clear |
( |
| ) |
|
|
inlinenoexcept |
◆ empty()
| bool openswmm::NameIndex::empty |
( |
| ) |
const |
|
inlinenoexcept |
True if no names are registered.
◆ find()
| int openswmm::NameIndex::find |
( |
std::string_view |
name | ) |
const |
|
inlinenoexcept |
Look up the index for a name.
- Parameters
-
- Returns
- Index, or -1 if not found.
◆ name_of()
| const std::string & openswmm::NameIndex::name_of |
( |
int |
idx | ) |
const |
|
inline |
Return the name for a given index.
- Exceptions
-
| std::out_of_range | if idx is out of bounds. |
◆ names()
| const std::vector< std::string > & openswmm::NameIndex::names |
( |
| ) |
const |
|
inlinenoexcept |
Read-only access to the ordered name list.
◆ reserve()
| void openswmm::NameIndex::reserve |
( |
std::size_t |
n | ) |
|
|
inline |
Pre-allocate for a known count (avoids rehash during input).
◆ size()
| int openswmm::NameIndex::size |
( |
| ) |
const |
|
inlinenoexcept |
Number of registered names.
◆ try_find()
| std::optional< int > openswmm::NameIndex::try_find |
( |
std::string_view |
name | ) |
const |
|
inlinenoexcept |
Look up the index, returning std::optional.
The documentation for this class was generated from the following file:
- /home/runner/work/openswmm.engine/openswmm.engine/src/engine/data/NameIndex.hpp