示例#1
0
文件: ActorSet.cs 项目: vb0067/LGame
 public bool Add(Actor actor)
 {
     if (this.Contains(actor))
     {
         return(false);
     }
     else
     {
         ++this.numActors;
         ActorSet.ListNode newNode = new ActorSet.ListNode(actor,
                                                           this.listHeadTail.prev);
         int seq = actor.GetSequenceNumber();
         if (this.numActors >= 2 * this.hashMap.Length)
         {
             this.Resize();
         }
         else
         {
             int hash = seq % this.hashMap.Length;
             ActorSet.ListNode hashHead = this.hashMap[hash];
             this.hashMap[hash] = newNode;
             newNode.SetHashListHead(hashHead);
         }
         this.code += seq;
         return(true);
     }
 }
示例#2
0
 public bool Add(Actor actor)
 {
     if (this.Contains(actor))
     {
         return false;
     }
     else
     {
         ++this.numActors;
         ActorSet.ListNode newNode = new ActorSet.ListNode(actor,
                 this.listHeadTail.prev);
         int seq = actor.GetSequenceNumber();
         if (this.numActors >= 2 * this.hashMap.Length)
         {
             this.Resize();
         }
         else
         {
             int hash = seq % this.hashMap.Length;
             ActorSet.ListNode hashHead = this.hashMap[hash];
             this.hashMap[hash] = newNode;
             newNode.SetHashListHead(hashHead);
         }
         this.code += seq;
         return true;
     }
 }
示例#3
0
文件: ActorSet.cs 项目: vb0067/LGame
        private ActorSet.ListNode GetActorNode(Actor actor)
        {
            if (this.hashMap.Length == 0)
            {
                return(null);
            }
            else
            {
                int seq  = actor.GetSequenceNumber();
                int hash = seq % this.hashMap.Length;
                ActorSet.ListNode hashHead = this.hashMap[hash];
                if (hashHead == null)
                {
                    return(null);
                }
                else if (hashHead.actor == actor)
                {
                    return(hashHead);
                }
                else
                {
                    for (ActorSet.ListNode curNode = hashHead.nextHash; curNode != hashHead; curNode = curNode.nextHash)
                    {
                        if (curNode.actor == actor)
                        {
                            return(curNode);
                        }
                    }

                    return(null);
                }
            }
        }
示例#4
0
文件: ActorSet.cs 项目: vb0067/LGame
 public bool Remove(Actor actor)
 {
     ActorSet.ListNode actorNode = this.GetActorNode(actor);
     if (actorNode != null)
     {
         this.Remove(actorNode);
         this.code -= actor.GetSequenceNumber();
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#5
0
文件: ActorSet.cs 项目: vb0067/LGame
        public void AddAll(Actor[] o)
        {
            int size = o.Length;

            this.numActors = size;
            this.Resize();
            for (int i = 0; i < size; i++)
            {
                Actor             actor   = o[i];
                ActorSet.ListNode newNode = new ActorSet.ListNode(actor,
                                                                  this.listHeadTail.prev);
                int seq  = actor.GetSequenceNumber();
                int hash = seq % this.hashMap.Length;
                ActorSet.ListNode hashHead = this.hashMap[hash];
                this.hashMap[hash] = newNode;
                newNode.SetHashListHead(hashHead);
                this.code += seq;
            }
        }
示例#6
0
 public bool Remove(Actor actor)
 {
     ActorSet.ListNode actorNode = this.GetActorNode(actor);
     if (actorNode != null)
     {
         this.Remove(actorNode);
         this.code -= actor.GetSequenceNumber();
         return true;
     }
     else
     {
         return false;
     }
 }
示例#7
0
        private ActorSet.ListNode GetActorNode(Actor actor)
        {
            if (this.hashMap.Length == 0)
            {
                return null;
            }
            else
            {
                int seq = actor.GetSequenceNumber();
                int hash = seq % this.hashMap.Length;
                ActorSet.ListNode hashHead = this.hashMap[hash];
                if (hashHead == null)
                {
                    return null;
                }
                else if (hashHead.actor == actor)
                {
                    return hashHead;
                }
                else
                {
                    for (ActorSet.ListNode curNode = hashHead.nextHash; curNode != hashHead; curNode = curNode.nextHash)
                    {
                        if (curNode.actor == actor)
                        {
                            return curNode;
                        }
                    }

                    return null;
                }
            }
        }