KiCad PCB EDA Suite
INTRUSIVE_LIST< T > Class Template Reference

< A lightweight intrusive list container More...

#include <intrusive_list.h>

Public Member Functions

 INTRUSIVE_LIST ()
 
void ListClear ()
 
T * ListRemove ()
 
int ListSize () const
 
void ListInsert (T *item)
 
T * ListNext () const
 
T * ListPrev () const
 

Private Attributes

int m_count
 
T * m_prev
 
T * m_next
 
T * m_root
 

Detailed Description

template<class T>
class INTRUSIVE_LIST< T >

< A lightweight intrusive list container

Definition at line 32 of file intrusive_list.h.

Constructor & Destructor Documentation

◆ INTRUSIVE_LIST()

template<class T >
INTRUSIVE_LIST< T >::INTRUSIVE_LIST ( )
inline

Definition at line 1 of file intrusive_list.h.

36 {
37 ListClear();
38 }

Member Function Documentation

◆ ListClear()

template<class T >
void INTRUSIVE_LIST< T >::ListClear ( )
inline

Definition at line 40 of file intrusive_list.h.

41 {
42 m_prev = nullptr;
43 m_next = nullptr;
44 m_root = (T*) this;
45 m_count = 1;
46 }

References INTRUSIVE_LIST< T >::m_count, INTRUSIVE_LIST< T >::m_next, INTRUSIVE_LIST< T >::m_prev, and INTRUSIVE_LIST< T >::m_root.

◆ ListInsert()

template<class T >
void INTRUSIVE_LIST< T >::ListInsert ( T *  item)
inline

Definition at line 76 of file intrusive_list.h.

77 {
78 if( !m_root )
79 m_root = item;
80
81 if( m_next )
82 m_next->m_prev = item;
83
84 item->m_prev = (T*) this;
85 item->m_next = m_next;
86 item->m_root = m_root;
87 m_root->m_count++;
88
89 m_next = item;
90 }

References INTRUSIVE_LIST< T >::m_next, and INTRUSIVE_LIST< T >::m_root.

◆ ListNext()

template<class T >
T * INTRUSIVE_LIST< T >::ListNext ( ) const
inline

Definition at line 92 of file intrusive_list.h.

92{ return m_next; };

References INTRUSIVE_LIST< T >::m_next.

◆ ListPrev()

template<class T >
T * INTRUSIVE_LIST< T >::ListPrev ( ) const
inline

Definition at line 93 of file intrusive_list.h.

93{ return m_prev; };

References INTRUSIVE_LIST< T >::m_prev.

◆ ListRemove()

template<class T >
T * INTRUSIVE_LIST< T >::ListRemove ( )
inline

Definition at line 48 of file intrusive_list.h.

49 {
50 if( m_prev )
51 m_prev->m_next = m_next;
52
53 if( m_next )
54 m_next->m_prev = m_prev;
55
56 m_root->m_count--;
57
58 T* rv = nullptr;
59
60 if( m_prev )
61 rv = m_prev;
62 else if( m_next )
63 rv = m_next;
64
65 m_root = nullptr;
66 m_prev = nullptr;
67 m_next = nullptr;
68 return rv;
69 }

References INTRUSIVE_LIST< T >::m_next, INTRUSIVE_LIST< T >::m_prev, and INTRUSIVE_LIST< T >::m_root.

◆ ListSize()

template<class T >
int INTRUSIVE_LIST< T >::ListSize ( ) const
inline

Definition at line 71 of file intrusive_list.h.

72 {
73 return m_root ? m_root->m_count : 0;
74 }

References INTRUSIVE_LIST< T >::m_root.

Member Data Documentation

◆ m_count

template<class T >
int INTRUSIVE_LIST< T >::m_count
private

Definition at line 96 of file intrusive_list.h.

Referenced by INTRUSIVE_LIST< T >::ListClear().

◆ m_next

◆ m_prev

template<class T >
T* INTRUSIVE_LIST< T >::m_prev
private

◆ m_root


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