Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
SkTInternalLList< T > Class Template Reference

#include <SkTInternalLList.h>

Classes

class  Iter
 

Public Member Functions

 SkTInternalLList ()
 
void reset ()
 
void remove (T *entry)
 
void addToHead (T *entry)
 
void addToTail (T *entry)
 
void addBefore (T *newEntry, T *existingEntry)
 
void addAfter (T *newEntry, T *existingEntry)
 
void concat (SkTInternalLList &&list)
 
bool isEmpty () const
 
Thead () const
 
Ttail () const
 
Iter begin () const
 
Iter end () const
 

Detailed Description

template<class T>
class SkTInternalLList< T >

This class implements a templated internal doubly linked list data structure.

Definition at line 29 of file SkTInternalLList.h.

Constructor & Destructor Documentation

◆ SkTInternalLList()

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

Definition at line 31 of file SkTInternalLList.h.

31{}

Member Function Documentation

◆ addAfter()

template<class T >
void SkTInternalLList< T >::addAfter ( T newEntry,
T existingEntry 
)
inline

Inserts a new list entry after an existing list entry. The new entry must not already be a member of this or any other list. If existingEntry is NULL then the new entry is added at the head.

Definition at line 136 of file SkTInternalLList.h.

136 {
137 SkASSERT(newEntry);
138
139 if (nullptr == existingEntry) {
140 this->addToHead(newEntry);
141 return;
142 }
143
144 SkASSERT(this->isInList(existingEntry));
145 newEntry->fPrev = existingEntry;
146 T* next = existingEntry->fNext;
147 existingEntry->fNext = newEntry;
148 newEntry->fNext = next;
149 if (nullptr == next) {
150 SkASSERT(fTail == existingEntry);
151 fTail = newEntry;
152 } else {
153 next->fPrev = newEntry;
154 }
155#ifdef SK_DEBUG
156 newEntry->fList = this;
157#endif
158 }
static float next(float f)
#define SkASSERT(cond)
Definition: SkAssert.h:116
void addToHead(T *entry)
#define T
Definition: precompiler.cc:65

◆ addBefore()

template<class T >
void SkTInternalLList< T >::addBefore ( T newEntry,
T existingEntry 
)
inline

Inserts a new list entry before an existing list entry. The new entry must not already be a member of this or any other list. If existingEntry is NULL then the new entry is added at the tail.

Definition at line 107 of file SkTInternalLList.h.

107 {
108 SkASSERT(newEntry);
109
110 if (nullptr == existingEntry) {
111 this->addToTail(newEntry);
112 return;
113 }
114
115 SkASSERT(this->isInList(existingEntry));
116 newEntry->fNext = existingEntry;
117 T* prev = existingEntry->fPrev;
118 existingEntry->fPrev = newEntry;
119 newEntry->fPrev = prev;
120 if (nullptr == prev) {
121 SkASSERT(fHead == existingEntry);
122 fHead = newEntry;
123 } else {
124 prev->fNext = newEntry;
125 }
126#ifdef SK_DEBUG
127 newEntry->fList = this;
128#endif
129 }
static float prev(float f)
void addToTail(T *entry)

◆ addToHead()

template<class T >
void SkTInternalLList< T >::addToHead ( T entry)
inline

Definition at line 64 of file SkTInternalLList.h.

64 {
65 SkASSERT(nullptr == entry->fPrev && nullptr == entry->fNext);
66 SkASSERT(nullptr == entry->fList);
67
68 entry->fPrev = nullptr;
69 entry->fNext = fHead;
70 if (fHead) {
71 fHead->fPrev = entry;
72 }
73 fHead = entry;
74 if (nullptr == fTail) {
75 fTail = entry;
76 }
77
78#ifdef SK_DEBUG
79 entry->fList = this;
80#endif
81 }

◆ addToTail()

template<class T >
void SkTInternalLList< T >::addToTail ( T entry)
inline

Definition at line 83 of file SkTInternalLList.h.

83 {
84 SkASSERT(nullptr == entry->fPrev && nullptr == entry->fNext);
85 SkASSERT(nullptr == entry->fList);
86
87 entry->fPrev = fTail;
88 entry->fNext = nullptr;
89 if (fTail) {
90 fTail->fNext = entry;
91 }
92 fTail = entry;
93 if (nullptr == fHead) {
94 fHead = entry;
95 }
96
97#ifdef SK_DEBUG
98 entry->fList = this;
99#endif
100 }

◆ begin()

template<class T >
Iter SkTInternalLList< T >::begin ( ) const
inline

Definition at line 249 of file SkTInternalLList.h.

249 {
250 Iter iter;
251 iter.init(*this, Iter::kHead_IterStart);
252 return iter;
253 }

◆ concat()

template<class T >
void SkTInternalLList< T >::concat ( SkTInternalLList< T > &&  list)
inline

Definition at line 160 of file SkTInternalLList.h.

160 {
161 if (list.isEmpty()) {
162 return;
163 }
164
165 list.fHead->fPrev = fTail;
166 if (!fHead) {
167 SkASSERT(!list.fHead->fPrev);
168 fHead = list.fHead;
169 } else {
170 SkASSERT(fTail);
171 fTail->fNext = list.fHead;
172 }
173 fTail = list.fTail;
174
175#ifdef SK_DEBUG
176 for (T* node = list.fHead; node; node = node->fNext) {
177 SkASSERT(node->fList == &list);
178 node->fList = this;
179 }
180#endif
181
182 list.fHead = list.fTail = nullptr;
183 }
bool isEmpty() const

◆ end()

template<class T >
Iter SkTInternalLList< T >::end ( ) const
inline

Definition at line 255 of file SkTInternalLList.h.

255{ return Iter(); }

◆ head()

template<class T >
T * SkTInternalLList< T >::head ( ) const
inline

Definition at line 190 of file SkTInternalLList.h.

190{ return fHead; }

◆ isEmpty()

template<class T >
bool SkTInternalLList< T >::isEmpty ( ) const
inline

Definition at line 185 of file SkTInternalLList.h.

185 {
186 SkASSERT(SkToBool(fHead) == SkToBool(fTail));
187 return !fHead;
188 }
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35

◆ remove()

template<class T >
void SkTInternalLList< T >::remove ( T entry)
inline

Definition at line 38 of file SkTInternalLList.h.

38 {
39 SkASSERT(fHead && fTail);
40 SkASSERT(this->isInList(entry));
41
42 T* prev = entry->fPrev;
43 T* next = entry->fNext;
44
45 if (prev) {
46 prev->fNext = next;
47 } else {
48 fHead = next;
49 }
50 if (next) {
51 next->fPrev = prev;
52 } else {
53 fTail = prev;
54 }
55
56 entry->fPrev = nullptr;
57 entry->fNext = nullptr;
58
59#ifdef SK_DEBUG
60 entry->fList = nullptr;
61#endif
62 }

◆ reset()

template<class T >
void SkTInternalLList< T >::reset ( )
inline

Definition at line 33 of file SkTInternalLList.h.

33 {
34 fHead = nullptr;
35 fTail = nullptr;
36 }

◆ tail()

template<class T >
T * SkTInternalLList< T >::tail ( ) const
inline

Definition at line 191 of file SkTInternalLList.h.

191{ return fTail; }

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