user-0 提问: 请问以下基于双向链表的直接插入排序正不正确?

回复:
user: user-1
content: 好像已经有个类似的帖子了，我已经回复了。交换两个结点的操作。这里不再赘述 再提供另外一种方案，如果你是在搞不清楚怎么交换，且结点数据域不多，那么采用这种方式最快捷，简单方便  比较需要交换,则交换数据，注意只交换数据，不要交换next，prev指针域	 { 	数据类型 temp; 		memcpy(temp, pList->CurItem->数据); 		memcpy(pList->CurItem->数据, pTmp->CurItem->数据); 		memcpy(pTmp->CurItem->数据, temp); }  over！

user: user-0
content: 以下是这种交换方式产生的串口信息, 看上去还正确一些  //exchange   A B<->C D  E pTmpA->CurItem->next = pTmpC->CurItem; //A->C B D pTmpC->CurItem->prev = pTmpA->CurItem;  //A<->C B D  pTmpB->CurItem->next = pTmpD->CurItem;  //A<->C B-> D pTmpD->CurItem->prev = pTmpB->CurItem;  //A<->C B<-> D  pTmpC->CurItem->next = pTmpB->CurItem;    //A<->C->B<-> D pTmpB->CurItem->prev=	 pTmpC->CurItem;  //A<->C<->B<-> D //exchange   .........0..........init.................filename: 155067.chm.....4.... .........0..........init.................filename: DAO360.CHM.....4.... .........0..........init.................filename: moviemk.chm.....4.... .........0..........init.................filename: wmplayer.chm.....4.... ......A: wmplayer.chm, B: 155067.chm, C: DAO360.CHM, D: moviemk.chm.....  ....exchage....DAO360.CHM..<-->..155067.chm....inloop 1..;.................................   .................outloop....i=1.............  ......A: wmplayer.chm, B: 155067.chm, C: DAO360.CHM, D: moviemk.chm.....  ....exchage....DAO360.CHM..<-->..155067.chm....inloop 2..;.......exchage....DAO360.CHM..<-->..155067.chm....inloop 1..;.................................   .................outloop....i=2.............  ......A: wmplayer.chm, B: 155067.chm, C: DAO360.CHM, D: moviemk.chm.....  ....exchage....DAO360.CHM..<-->..155067.chm....inloop 3..;.......exchage....DAO360.CHM..<-->..155067.chm....inloop 2..;.......exchage....DAO360.CHM..<-->..155067.chm....inloop 1..;.................................   .................outloop....i=3.............

user: user-0
content: 引用 1 楼 user-2 的回复:参考下 a b 互换 a->prev->next = b;  b->prev = a->prev a->next = b->next;  b->next->prev = a;            b->next = a; a->prev = b;  试过了,换位有问题. 程序的排序框架也可能有问题.  以下是串口信息:...........................  .........0..........init.................filename: 155067.chm.....4.... .........0..........init.................filename: DAO360.CHM.....4.... .........0..........init.................filename: moviemk.chm.....4.... .........0..........init.................filename: wmplayer.chm.....4.... ......A: wmplayer.chm, B: 155067.chm, C: DAO360.CHM, D: moviemk.chm.....  ....exchage....DAO360.CHM..<-->..155067.chm....inloop 1..;.................................   .................outloop....i=1.............  ......A: wmplayer.chm, B: 155067.chm, C: DAO360.CHM, D: moviemk.chm.....  ....exchage....DAO360.CHM..<-->..155067.chm....inloop 2..;.......exchage....DAO360.CHM..<-->..155067.chm....inloop 1..;.................................   .................outloop....i=2.............  ......A: wmplayer.chm, B: 155067.chm, C: DAO360.CHM, D: moviemk.chm.....  ....exchage....DAO360.CHM..<-->..155067.chm....inloop 3..;.......exchage....DAO360.CHM..<-->..155067.chm....inloop 2..;.......exchage....DAO360.CHM..<-->..155067.chm....inloop 1..;.................................   .................outloop....i=3.............

user: user-2
content: 参考下 a b 互换 a->prev->next = b;  b->prev = a->prev a->next = b->next;  b->next->prev = a;            b->next = a; a->prev = b;