链表宏

 #define Destroy(_p) {if (((layer_type *)(_p))->Canvas != NULL) delete[] ((layer_type *)(_p))->Canvas; free(_p);}

 #define Destroy_(Head, _p) {if (((layer_type *)(_p))->src == (ListNode *)((layer_type *)(_p))) \
                              SrcReplace((Head), ((layer_type *)(_p))); \
                             delete[] ((layer_type *)(_p))->Canvas; free(_p);}

 #define InsertFromHead(Head, _p) {(_p)->next = (Head)->next; ((_p)->prev = (ListNode *)(Head))->next = (ListNode *)(_p); \
           if ((Head)->tail == NULL) (Head)->tail = (ListNode *)(_p); \
           else ((layer_type *)(_p)->next)->prev = (ListNode *)(_p);}

 #define NextInsert(TargetNode, NewNode) {if (((NewNode)->next = (TargetNode)->next) == NULL) \
           m_LayerListHead->tail = (ListNode *)(NewNode); \
           else ((layer_type *)(NewNode)->next)->prev = (ListNode *)(NewNode); \
           ((layer_type *)((TargetNode)->next = (ListNode *)(NewNode)))->prev = (ListNode *)(TargetNode);}

 #define PriorInsert(TargetNode, NewNode) {((NewNode)->prev = (TargetNode)->prev)->next = (ListNode *)(NewNode); \
           ((layer_type *)((NewNode)->next = (ListNode *)(TargetNode)))->prev = (ListNode *)(NewNode);}

 #define RemoveLayer_(Head, Node, bDel) {bool bfirstnode = ((Node) == (layer_type *)(Head)->next); \
           if (((Node)->prev->next = (Node)->next) != NULL) { \
            ((layer_type *)(Node)->next)->prev = (Node)->prev; } else { \
            (Head)->tail = ((Head)->next == NULL) ? NULL : (Node)->prev; } \
           (Head)->curActive = (layer_type *)((!bfirstnode) ? (Node)->prev : (Head)->next); (Head)->Count--; \
           if (bDel) Destroy_((Head), (Node));}

 #define RemoveLayerTo(_p, From, To) {RemoveLayer_((From), (_p), false); InsertFromHead((To), (_p));}

 #define SrcReplaceEach(List, SrcList) {layer_type* _p = (layer_type *)(SrcList)->next; while(_p) \
                                       {if (_p->src == _p) SrcReplace((List), _p); _p = (layer_type *)_p->next;}}

 #define RemoveLayers(Head, FirstNode, LastNode) {if ((FirstNode->prev->next = LastNode->next) != NULL) { \
                                                  ((layer_type *)LastNode->next)->prev = FirstNode->prev;} else { \
                                                  Head->tail = (Head->next == NULL) ? NULL : FirstNode->prev;}}

 #define InsertNodesFromHead(Head, FirstNode, LastNode) {(LastNode)->next = (Head)->next; \
          ((FirstNode)->prev = (ListNode *)(Head))->next = (ListNode *)(FirstNode); if ((Head)->tail == NULL) \
          (Head)->tail = (ListNode *)(LastNode); else ((layer_type *)(LastNode)->next)->prev = (ListNode *)(LastNode);}

 #define RemoveNodesTo(FirstNode, LastNode, From, To) {RemoveLayers((From), (FirstNode), (LastNode)); \
                                                       InsertNodesFromHead((To), (FirstNode), (LastNode));}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值