ONE - On-device Neural Engine
Loading...
Searching...
No Matches
coco::DLinkedList< Child, Parent >::Head Class Reference

#include <DLinkedList.h>

Public Member Functions

 Head (Parent *parent)
 
 Head (const Head &)=delete
 
 Head (Head &&)=delete
 
Child * head (void) const
 
Child * tail (void) const
 
bool empty (void) const
 
void enlist (Child *child)
 
void delist (Child *child)
 
void prepend (Child *child)
 
void append (Child *child)
 

Detailed Description

template<typename Child, typename Parent>
class coco::DLinkedList< Child, Parent >::Head

Definition at line 34 of file DLinkedList.h.

Constructor & Destructor Documentation

◆ Head() [1/3]

template<typename Child , typename Parent >
coco::DLinkedList< Child, Parent >::Head::Head ( Parent *  parent)
inline

Definition at line 37 of file DLinkedList.h.

37 : _parent{parent}
38 {
39 _head = nullptr;
40 _tail = nullptr;
41 }

◆ Head() [2/3]

template<typename Child , typename Parent >
coco::DLinkedList< Child, Parent >::Head::Head ( const Head )
delete

◆ Head() [3/3]

template<typename Child , typename Parent >
coco::DLinkedList< Child, Parent >::Head::Head ( Head &&  )
delete

Member Function Documentation

◆ append()

◆ delist()

template<typename Child , typename Parent >
void coco::DLinkedList< Child, Parent >::Head::delist ( Child *  child)
inline

Definition at line 101 of file DLinkedList.h.

102 {
103 assert(child->parent() == _parent);
104 assert(!empty());
105
106 // Notify Child-Leaving event
107 leaving(_parent, child);
108
109 if (child == _head)
110 {
111 _head = child->next();
112 }
113
114 if (child == _tail)
115 {
116 _tail = child->prev();
117 }
118
119 // Update parent-child relation
120 child->parent(nullptr);
121 }
static void leaving(Parent *, Child *)
A hook for Child-Leave event.

References coco::DLinkedList< Child, Parent >::Head::empty(), and coco::DLinkedList< Child, Parent >::leaving().

Referenced by coco::DLinkedList< Child, Parent >::Node::detach().

◆ empty()

template<typename Child , typename Parent >
bool coco::DLinkedList< Child, Parent >::Head::empty ( void  ) const
inline

Definition at line 52 of file DLinkedList.h.

53 {
54 if (_head == nullptr)
55 {
56 assert(_head == _tail);
57 return true;
58 }
59
60 assert(_head != nullptr);
61 assert(_tail != nullptr);
62 return false;
63 }

Referenced by coco::DLinkedList< Child, Parent >::Head::append(), coco::DLinkedList< Child, Parent >::Head::delist(), coco::DLinkedList< Child, Parent >::Head::enlist(), and coco::DLinkedList< Child, Parent >::Head::prepend().

◆ enlist()

template<typename Child , typename Parent >
void coco::DLinkedList< Child, Parent >::Head::enlist ( Child *  child)
inline

Definition at line 66 of file DLinkedList.h.

67 {
68 assert((child->prev() == nullptr) || (child->prev()->parent() == _parent));
69 assert((child->next() == nullptr) || (child->next()->parent() == _parent));
70
71 if (empty())
72 {
73 _head = child;
74 _tail = child;
75 }
76 else
77 {
78 if (child->next() == _head)
79 {
80 // _child is a new head
81 assert(child->prev() == nullptr);
82 _head = child;
83 }
84
85 if (child->prev() == _tail)
86 {
87 // _child is a new tail
88 assert(child->next() == nullptr);
89 _tail = child;
90 }
91 }
92
93 // Update parent-child relation
94 child->parent(_parent);
95
96 // Notify Child-Joining event
97 joined(_parent, child);
98 }
static void joined(Parent *, Child *)
A hook for Child-Join event.

References coco::DLinkedList< Child, Parent >::Head::empty(), and coco::DLinkedList< Child, Parent >::joined().

Referenced by coco::DLinkedList< Child, Parent >::Head::append(), coco::DLinkedList< Child, Parent >::Node::insertAfter(), coco::DLinkedList< Child, Parent >::Node::insertBefore(), and coco::DLinkedList< Child, Parent >::Head::prepend().

◆ head()

template<typename Child , typename Parent >
Child * coco::DLinkedList< Child, Parent >::Head::head ( void  ) const
inline

Definition at line 48 of file DLinkedList.h.

48{ return _head; }

Referenced by enco::HostBlockCompiler::compile(), dump(), dump(), and enco::validate_output_shape().

◆ prepend()

template<typename Child , typename Parent >
void coco::DLinkedList< Child, Parent >::Head::prepend ( Child *  child)
inline

Definition at line 124 of file DLinkedList.h.

125 {
126 if (empty())
127 {
128 enlist(child);
129 }
130 else
131 {
132 child->insertBefore(_head);
133 }
134 }

References coco::DLinkedList< Child, Parent >::Head::empty(), and coco::DLinkedList< Child, Parent >::Head::enlist().

◆ tail()

template<typename Child , typename Parent >
Child * coco::DLinkedList< Child, Parent >::Head::tail ( void  ) const
inline

Definition at line 49 of file DLinkedList.h.

49{ return _tail; }

The documentation for this class was generated from the following file: