Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
0
 private void Resize(int size)
 {
     this.hashMap = new ActorSet.ListNode[size];
     for (ActorSet.ListNode currentActor = this.listHeadTail.next; currentActor != this.listHeadTail; currentActor = currentActor.next)
     {
         int seq  = currentActor.actor.GetSequenceNumber();
         int hash = seq % size;
         ActorSet.ListNode hashHead = this.hashMap[hash];
         this.hashMap[hash] = currentActor;
         currentActor.SetHashListHead(hashHead);
     }
 }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
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;
     }
 }
Ejemplo n.º 5
0
 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;
     }
 }