Skip to content

Commit 35c7fdf

Browse files
临时暂存
1 parent d10a06a commit 35c7fdf

File tree

6 files changed

+381
-64
lines changed

6 files changed

+381
-64
lines changed

include/YY/Base/Containers/DoublyLinkedList.h

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace YY
4545
DoublyLinkedList(const DoublyLinkedList&) = delete;
4646
DoublyLinkedList& operator=(const DoublyLinkedList&) = delete;
4747

48-
DoublyLinkedList __YYAPI Flush() noexcept
48+
constexpr DoublyLinkedList __YYAPI Flush() noexcept
4949
{
5050
DoublyLinkedList _oList;
5151
_oList.pFirst = pFirst;
@@ -173,6 +173,20 @@ namespace YY
173173

174174
void __YYAPI Remove(_In_ EntryType* _pEntry) noexcept
175175
{
176+
#ifdef _DEBUG
177+
// 调试模式下检查节点是否在链表中
178+
bool bFound = false;
179+
for (auto _pCur = pFirst; _pCur != nullptr; _pCur = _pCur->pNext)
180+
{
181+
if (_pCur == _pEntry)
182+
{
183+
bFound = true;
184+
break;
185+
}
186+
}
187+
assert(bFound && "The entry to be removed is not in the list.");
188+
#endif
189+
176190
auto _pPrior = _pEntry->pPrior;
177191
_pEntry->pPrior = nullptr;
178192
auto _pNext = _pEntry->pNext;
@@ -184,7 +198,11 @@ namespace YY
184198
}
185199
else
186200
{
187-
assert(pFirst == _pEntry);
201+
if (pFirst != _pEntry)
202+
{
203+
assert(false && "_pEntry按预期应该是再头部。");
204+
return;
205+
}
188206
pFirst = _pNext;
189207
}
190208

@@ -194,7 +212,11 @@ namespace YY
194212
}
195213
else
196214
{
197-
assert(pLast == _pEntry);
215+
if (pLast != _pEntry)
216+
{
217+
assert(false && "_pEntry按预期应该是再尾部。");
218+
return;
219+
}
198220
pLast = _pPrior;
199221
}
200222
}

0 commit comments

Comments
 (0)