mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
added InsertAscending/DecendingListFIFO
simplified InsertAscending/DescendingList svn path=/trunk/; revision=7752
This commit is contained in:
parent
bec36ebaf9
commit
28618ae6f8
1 changed files with 53 additions and 34 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rtl.h,v 1.22 2003/12/31 11:33:07 hbirr Exp $
|
/* $Id: rtl.h,v 1.23 2004/01/18 22:28:48 gdalsnes Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -364,64 +364,83 @@ RemoveTailList (
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Macros for sorted inserts. Lists are walked in reverse order to maintain
|
* FIFO versions are slower but ensures that entries with equal SortField value
|
||||||
FIFO behaviour required by some callers...
|
* are placed in FIFO order (assuming that entries are removed from Head).
|
||||||
|
*/
|
||||||
|
|
||||||
VOID InsertXcendingList(
|
#define InsertAscendingListFIFO(ListHead, Type, ListEntryField, NewEntry, SortField)\
|
||||||
PLIST_ENTRY ListHead,
|
|
||||||
PLIST_ENTRY NewEntry,
|
|
||||||
...
|
|
||||||
|
|
||||||
-Gunnar
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define InsertDescendingList(ListHead, NewEntry, Type, ListEntryField, SortField)\
|
|
||||||
{\
|
{\
|
||||||
PLIST_ENTRY current;\
|
PLIST_ENTRY current;\
|
||||||
BOOL Inserted = FALSE;\
|
|
||||||
\
|
\
|
||||||
current = (ListHead)->Blink;\
|
current = (ListHead)->Flink;\
|
||||||
while (current != (ListHead))\
|
while (current != (ListHead))\
|
||||||
{\
|
{\
|
||||||
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >=\
|
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >\
|
||||||
CONTAINING_RECORD((NewEntry), Type, ListEntryField)->SortField)\
|
(NewEntry)->SortField)\
|
||||||
{\
|
{\
|
||||||
InsertHeadList(current, (NewEntry));\
|
|
||||||
Inserted = TRUE;\
|
|
||||||
break;\
|
break;\
|
||||||
}\
|
}\
|
||||||
current = current->Blink;\
|
current = current->Flink;\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
if (!Inserted)\
|
InsertTailList(current, &((NewEntry)->ListEntryField));\
|
||||||
{\
|
|
||||||
InsertHeadList((ListHead), (NewEntry));\
|
|
||||||
}\
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField)\
|
#define InsertDescendingListFIFO(ListHead, Type, ListEntryField, NewEntry, SortField)\
|
||||||
{\
|
{\
|
||||||
PLIST_ENTRY current;\
|
PLIST_ENTRY current;\
|
||||||
BOOL Inserted = FALSE;\
|
|
||||||
\
|
\
|
||||||
current = (ListHead)->Blink;\
|
current = (ListHead)->Flink;\
|
||||||
|
while (current != (ListHead))\
|
||||||
|
{\
|
||||||
|
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField <\
|
||||||
|
(NewEntry)->SortField)\
|
||||||
|
{\
|
||||||
|
break;\
|
||||||
|
}\
|
||||||
|
current = current->Flink;\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
InsertTailList(current, &((NewEntry)->ListEntryField));\
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define InsertAscendingList(ListHead, Type, ListEntryField, NewEntry, SortField)\
|
||||||
|
{\
|
||||||
|
PLIST_ENTRY current;\
|
||||||
|
\
|
||||||
|
current = (ListHead)->Flink;\
|
||||||
|
while (current != (ListHead))\
|
||||||
|
{\
|
||||||
|
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField >=\
|
||||||
|
(NewEntry)->SortField)\
|
||||||
|
{\
|
||||||
|
break;\
|
||||||
|
}\
|
||||||
|
current = current->Flink;\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
InsertTailList(current, &((NewEntry)->ListEntryField));\
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define InsertDescendingList(ListHead, Type, ListEntryField, NewEntry, SortField)\
|
||||||
|
{\
|
||||||
|
PLIST_ENTRY current;\
|
||||||
|
\
|
||||||
|
current = (ListHead)->Flink;\
|
||||||
while (current != (ListHead))\
|
while (current != (ListHead))\
|
||||||
{\
|
{\
|
||||||
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField <=\
|
if (CONTAINING_RECORD(current, Type, ListEntryField)->SortField <=\
|
||||||
CONTAINING_RECORD((NewEntry), Type, ListEntryField)->SortField)\
|
(NewEntry)->SortField)\
|
||||||
{\
|
{\
|
||||||
InsertHeadList(current, (NewEntry));\
|
|
||||||
Inserted = TRUE;\
|
|
||||||
break;\
|
break;\
|
||||||
}\
|
}\
|
||||||
current = current->Blink;\
|
current = current->Flink;\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
if (!Inserted)\
|
InsertTailList(current, &((NewEntry)->ListEntryField));\
|
||||||
{\
|
|
||||||
InsertHeadList((ListHead), (NewEntry));\
|
|
||||||
}\
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue