NamedVector¶
-
template<typename T>
class NamedVector¶ Ordered, name-indexed vector: a
std::vector<T>where every entry also has a unique string key.The container behind every compute-graph
Function’s named inputs and outputs (NamedVector<Value>) and type lists (NamedVector<Type>), preserving insertion order while supporting both integer indexing and lookup by name.Public Functions
-
NamedVector() = default¶
Empty vector.
-
inline NamedVector(const std::vector<std::string> &keys, const std::vector<T> &values)¶
One entry per pair of
keysandvalues, in order.
-
inline NamedVector(const std::initializer_list<std::pair<std::string, T>> &items)¶
One entry per
(key, value)pair ofitems, in order.
-
inline NamedVector(const std::vector<std::pair<std::string, T>> &items)¶
One entry per
(key, value)pair ofitems, in order.
-
inline const std::unordered_map<std::string, std::size_t> &index_map() const¶
Map from key to its position in values.
-
inline std::vector<std::string> keys() const¶
The keys, in insertion order.
-
inline decltype(auto) begin()¶
Iterator over the values, in insertion order.
-
inline decltype(auto) begin() const¶
-
inline decltype(auto) rbegin()¶
-
inline decltype(auto) rbegin() const¶
-
inline decltype(auto) end()¶
-
inline decltype(auto) end() const¶
-
inline decltype(auto) rend()¶
-
inline decltype(auto) rend() const¶
-
inline decltype(auto) front()¶
The first value.
-
inline decltype(auto) front() const¶
The first value.
-
inline decltype(auto) back()¶
The last value.
-
inline decltype(auto) back() const¶
The last value.
-
inline bool empty() const¶
Whether the vector holds no entries.
-
inline std::size_t size() const¶
Number of entries.
-
inline void reserve(std::size_t capacity)¶
Reserve storage for
capacityentries.
-
inline void push_back(const std::string &key, const T &value)¶
Append
valueunder a newkey;keymust not already be present.
-
inline void insert_back(const NamedVector<T> &other)¶
Append every entry of
other; its keys must not already be present.
-
inline NamedVector<T> sort_like(const std::unordered_map<std::string, std::size_t> &index_map) const¶
A copy reordered to match
index_map(same keys, same key-to-position mapping as this instance’s, just reassigned).
-
NamedVector() = default¶