LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
infer_lqn_findbyname.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012-2026, QORE Lab, Imperial College London
3
* All rights reserved.
4
*/
5
#ifndef LINE_API_INFER_INFER_LQN_FINDBYNAME_H
6
#define LINE_API_INFER_INFER_LQN_FINDBYNAME_H
7
8
/**
9
* @file
10
* @ingroup api_infer
11
* First element of a named LQN container matching a name.
12
*
13
* Port of matlab/src/api/infer/infer_lqn_findbyname.m. No JAR counterpart.
14
*
15
* MATLAB walks a cell array of LQN element handles and returns the first whose
16
* .name equals the argument, or [] when none does. The handle itself belongs
17
* to the LayeredNetwork model layer, which this phase of the port does not
18
* carry, so what crosses is the lookup: the container is the name list
19
* (LayeredNetworkStruct.names, the same list infer_lqn_getobs indexes) and the
20
* result is the POSITION of the match, which the caller uses to index whatever
21
* parallel array holds its elements.
22
*
23
* The MATLAB is a linear scan returning the FIRST match, and duplicates are
24
* not diagnosed; the port keeps both properties, since an LQN with two
25
* elements of one name resolves consistently between the two implementations
26
* only if they agree on which one wins.
27
*
28
* ARITHMETIC: none. String comparison only, so the function is not templated
29
* on the number type and is usable from every instantiation.
30
*/
31
32
#include <cstddef>
33
#include <string>
34
#include <vector>
35
36
namespace
line
{
37
namespace
infer
{
38
39
/** Returned when no element carries the requested name, MATLAB's []. */
40
static
const
std::size_t
INFER_LQN_NOT_FOUND
=
static_cast<
std::size_t
>
(-1);
41
42
/**
43
* @brief First element of a named LQN container matching a name.
44
*
45
* @param names container of element names, in element order
46
* @param name name to locate
47
* @return index of the first match, or INFER_LQN_NOT_FOUND
48
*/
49
inline
std::size_t
infer_lqn_findbyname
(
const
std::vector<std::string>& names,
50
const
std::string& name) {
51
for
(std::size_t k = 0; k < names.size(); ++k)
52
if
(names[k] == name)
return
k;
53
return
INFER_LQN_NOT_FOUND
;
54
}
55
56
}
// namespace infer
57
}
// namespace line
58
59
#endif
// LINE_API_INFER_INFER_LQN_FINDBYNAME_H
line::infer
Definition
infer_compute_ql_at_arrival.h:39
line::infer::INFER_LQN_NOT_FOUND
static const std::size_t INFER_LQN_NOT_FOUND
Returned when no element carries the requested name, MATLAB's [].
Definition
infer_lqn_findbyname.h:40
line::infer::infer_lqn_findbyname
std::size_t infer_lqn_findbyname(const std::vector< std::string > &names, const std::string &name)
First element of a named LQN container matching a name.
Definition
infer_lqn_findbyname.h:49
line
Definition
aoi_dist2ph.h:52
include
line
api
infer
infer_lqn_findbyname.h
Generated by
1.18.0