예제 #1
0
        /// <summary>
        /// 清空链表
        /// </summary>
        public void Clear()
        {
            while (head != null)
            {
                var node = head;
                head      = head.next;
                node.pre  = null;
                node.next = null;
            }

            tail  = null;
            Count = 0;
        }
예제 #2
0
        private bool _ContainsNode(EntityNode node)
        {
            var p = head;

            while (p != null)
            {
                if (p == node)
                {
                    return(true);
                }

                p = p.next;
            }
            return(false);
        }
예제 #3
0
        /// <summary>
        /// 尾插法添加结点
        /// </summary>
        /// <param name="node"></param>
        public void AddEntity(CEntity entity)
        {
            EntityNode node = PopNode();

            node.Entity = entity;
            node.pre    = tail;
            node.next   = null;

            if (tail != null)
            {
                tail.next = node;
            }
            tail = node;

            if (head == null)
            {
                head = node;
            }

            Count++;
        }
예제 #4
0
        /// <summary>
        /// 删除结点
        /// 使用此方法请确保Entity在EntityList中,否则,使用RemoveBool代替
        /// </summary>
        /// <param name="entity"></param>
        private void _RemoveNode(EntityNode node)
        {
#if DEBUG
            if (_ContainsNode(node) == false)
            {
                CLog.Warning(SysLogType.Battle, "entity not exit in this entityList.entity.baseid={0}", node.Entity.BaseId);
                return;
            }
#endif

            EntityNode pre  = node.pre;
            EntityNode next = node.next;

            if (head == node)
            {
                head = next;
            }

            if (tail == node)
            {
                tail = pre;
            }

            if (pre != null)
            {
                pre.next = next;
            }

            if (next != null)
            {
                next.pre = pre;
            }

            _DisposeNode(node);

            Count--;
        }
예제 #5
0
 private void _DisposeNode(EntityNode node)
 {
     node.Dispose();
     s_NodePool.Push(node);
 }