graph_node_list.h#
Intrusive doubly-linked list used exclusively for Graph node lists.
Provides generic_graph_node_list and generic_graph_node_list_iterator, together with concrete type aliases for mutable and const graph node lists.
- Attention
The code in this file is highly EXPERIMENTAL. The APIs will probably change.
-
namespace onnx_light
Alias that makes onnx-light headers compatible with code that references
ONNX_LIGHT_NAMESPACE(the macro used in the standard onnx package).Set to
ONNX_LIGHT_NAMESPACEso both names resolve to the same namespace.Symbol-visibility attribute for the public onnx-light C++ API.
Defined as empty because onnx-light does not require explicit
__declspec(dllexport)or__attribute__((visibility("default")))annotations — visibility is controlled at the shared-library level. The macro is provided so that vendored ONNX headers that decorate their declarations withONNX_APIcompile without modification.Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal
onnxnamespace — rather than theONNX_NAMESPACEmacro — resolves to the onnx-light namespace. The standard onnx package lives innamespace onnx; onnx-light usesonnx_light(via ONNX_LIGHT_NAMESPACE), so this alias keeps onnx-light a true drop-in. It is only introduced when the onnx-light namespace differs fromonnx.Typedefs
-
using graph_node_list = generic_graph_node_list<Node>#
Mutable graph node list over
Nodeelements.
-
using const_graph_node_list = generic_graph_node_list<const Node>#
Read-only graph node list over
const Nodeelements.
-
using graph_node_list_iterator = generic_graph_node_list_iterator<Node>#
Mutable iterator over a
graph_node_list.
-
using const_graph_node_list_iterator = generic_graph_node_list_iterator<const Node>#
Read-only iterator over a
const_graph_node_list.
Functions
-
template<typename T>
static inline bool operator==(generic_graph_node_list_iterator<T> a, generic_graph_node_list_iterator<T> b)# Equality comparison for two iterators.
Two iterators compare equal when they point to the same node.
- Template Parameters:
T – Element type.
- Parameters:
a – Left-hand iterator.
b – Right-hand iterator.
- Returns:
trueif both iterators point to the same node.
-
template<typename T>
static inline bool operator!=(generic_graph_node_list_iterator<T> a, generic_graph_node_list_iterator<T> b)# Inequality comparison for two iterators.
- Template Parameters:
T – Element type.
- Parameters:
a – Left-hand iterator.
b – Right-hand iterator.
- Returns:
trueif the iterators point to different nodes.
Variables
-
static constexpr size_t kNextDirection = 0#
Direction index for forward (next-pointer) traversal.
-
static constexpr size_t kPrevDirection = 1#
Direction index for reverse (previous-pointer) traversal.
-
template<typename T>
struct generic_graph_node_list# - #include <graph_node_list.h>
Intrusive doubly-linked list view over graph nodes.
Does not own the nodes; it merely provides a range interface around the sentinel
headpointer and a traversal direction. Supports both forward (begin/end) and reverse (rbegin/rend) iteration. A reversed view of the same list is obtained viareverse().Public Types
-
using iterator = generic_graph_node_list_iterator<T>#
Mutable iterator type.
-
using const_iterator = generic_graph_node_list_iterator<const T>#
Read-only iterator type.
Public Functions
-
inline generic_graph_node_list_iterator<T> begin()#
Returns a mutable iterator to the first element.
-
inline generic_graph_node_list_iterator<const T> begin() const#
Returns a read-only iterator to the first element.
-
inline generic_graph_node_list_iterator<T> end()#
Returns a mutable past-the-end iterator (points at the sentinel).
-
inline generic_graph_node_list_iterator<const T> end() const#
Returns a read-only past-the-end iterator (points at the sentinel).
-
inline generic_graph_node_list_iterator<T> rbegin()#
Returns a mutable iterator to the first element of the reverse sequence.
-
inline generic_graph_node_list_iterator<const T> rbegin() const#
Returns a read-only iterator to the first element of the reverse sequence.
-
inline generic_graph_node_list_iterator<T> rend()#
Returns a mutable past-the-end iterator for the reverse sequence.
-
inline generic_graph_node_list_iterator<const T> rend() const#
Returns a read-only past-the-end iterator for the reverse sequence.
-
inline generic_graph_node_list reverse()#
Returns a view of the same list traversed in the opposite direction.
The returned object shares the same sentinel head but uses the opposite direction index, so iterating it yields nodes in reverse order.
- Returns:
A
generic_graph_node_listwith the direction index flipped.
-
inline generic_graph_node_list reverse() const#
Returns a view of the same list traversed in the opposite direction.
The returned object shares the same sentinel head but uses the opposite direction index, so iterating it yields nodes in reverse order.
- Returns:
A
generic_graph_node_listwith the direction index flipped.
-
using iterator = generic_graph_node_list_iterator<T>#
-
template<typename T>
struct generic_graph_node_list_iterator# - #include <graph_node_list.h>
Bidirectional iterator for
generic_graph_node_list.The iterator stores a raw pointer to the current node and a direction index so that the same class serves both forward and reverse traversal. Incrementing follows the
kNextDirectionlinks; decrementing follows the opposite direction.Public Types
-
using difference_type = int64_t#
Public Functions
-
inline generic_graph_node_list_iterator()#
Constructs an iterator that compares equal to a default-constructed
end().
-
inline generic_graph_node_list_iterator(T *cur, size_t d)#
Constructs an iterator pointing at
curtraversing in directiond.- Parameters:
cur – Pointer to the current node (may be the sentinel head).
d – Traversal direction:
kNextDirection(0) orkPrevDirection(1).
-
inline generic_graph_node_list_iterator &operator++()#
Pre-increment: advances to the next node in the traversal direction.
- Returns:
Reference to this iterator after the advance.
-
inline generic_graph_node_list_iterator operator++(int)#
Post-increment: advances to the next node and returns the previous state.
- Returns:
Copy of this iterator before the advance.
-
inline generic_graph_node_list_iterator &operator--()#
Pre-decrement: moves to the preceding node in the traversal direction.
- Returns:
Reference to this iterator after the move.
-
inline generic_graph_node_list_iterator operator--(int)#
Post-decrement: moves to the preceding node and returns the previous state.
- Returns:
Copy of this iterator before the move.
-
inline void destroyCurrent()#
Destroys the current node without invalidating this iterator.
After the call, the iterator points to the node that preceded the destroyed node in the traversal direction. Named
destroyCurrent(rather thandestroy) so that accidental->/.mixups do not silently call the wrong function.
-
inline generic_graph_node_list_iterator reverse()#
Returns an iterator that traverses in the opposite direction, still pointing at the same node.
- Returns:
A new iterator with the direction index flipped.
Private Functions
-
inline size_t reverseDir()#
Returns the direction index opposite to the current traversal direction.
-
using difference_type = int64_t#
-
using graph_node_list = generic_graph_node_list<Node>#