Esempio n. 1
0
        public void AddAgent(Agent pAgent)
        {
            int id       = pAgent.GetId();
            int priority = pAgent.GetPriority();
            int num3     = -1;

            for (int i = 0; i < this.Agents.Count; i++)
            {
                HeapItem_t _t2 = this.Agents[i];
                if (_t2.priority == priority)
                {
                    num3 = i;
                    break;
                }
            }
            if (num3 == -1)
            {
                HeapItem_t item = new HeapItem_t {
                    agents   = new DictionaryView <int, Agent>(),
                    priority = priority
                };
                item.agents[id] = pAgent;
                this.Agents.Add(item);
            }
            else
            {
                HeapItem_t _t3 = this.Agents[num3];
                _t3.agents[id] = pAgent;
            }
        }
Esempio n. 2
0
        public void AddAgent(Agent pAgent)
        {
            int id       = pAgent.GetId();
            int priority = pAgent.GetPriority();
            int num      = -1;

            for (int i = 0; i < this.Agents.get_Count(); i++)
            {
                if (this.Agents.get_Item(i).priority == priority)
                {
                    num = i;
                    break;
                }
            }
            if (num == -1)
            {
                World.HeapItem_t heapItem_t = default(World.HeapItem_t);
                heapItem_t.agents   = new DictionaryView <int, Agent>();
                heapItem_t.priority = priority;
                heapItem_t.agents.set_Item(id, pAgent);
                this.Agents.Add(heapItem_t);
            }
            else
            {
                this.Agents.get_Item(num).agents.set_Item(id, pAgent);
            }
        }
Esempio n. 3
0
        public void RemoveAgent(Agent pAgent)
        {
            int id       = pAgent.GetId();
            int priority = pAgent.GetPriority();
            int num3     = -1;

            for (int i = 0; i < this.Agents.Count; i++)
            {
                HeapItem_t _t = this.Agents[i];
                if (_t.priority == priority)
                {
                    num3 = i;
                    break;
                }
            }
            if (num3 != -1)
            {
                HeapItem_t _t2 = this.Agents[num3];
                if (_t2.agents.ContainsKey(id))
                {
                    HeapItem_t _t3 = this.Agents[num3];
                    _t3.agents.Remove(id);
                }
            }
        }
Esempio n. 4
0
        public void RemoveAgent(Agent pAgent)
        {
            //ASSERT_MAIN_THREAD();

            int agentId   = pAgent.GetId();
            int priority  = pAgent.GetPriority();
            int itemIndex = this.Agents.FindIndex(delegate(HeapItem_t h) { return(h.priority == priority); });

            if (itemIndex != -1)
            {
                if (this.Agents[itemIndex].agents.ContainsKey(agentId))
                {
                    this.Agents[itemIndex].agents.Remove(agentId);
                }
            }
        }
Esempio n. 5
0
        private void removeAgent_(Agent pAgent)
        {
            int agentId   = pAgent.GetId();
            int priority  = pAgent.GetPriority();
            int itemIndex = this.Agents.FindIndex(delegate(HeapItem_t h)
            {
                return(h.priority == priority);
            });

            if (itemIndex != -1)
            {
                if (this.Agents[itemIndex].agents.ContainsKey(agentId))
                {
                    this.Agents[itemIndex].agents.Remove(agentId);
                }
            }
        }
Esempio n. 6
0
        public void RemoveAgent(Agent pAgent)
        {
            int id       = pAgent.GetId();
            int priority = pAgent.GetPriority();
            int num      = -1;

            for (int i = 0; i < this.Agents.get_Count(); i++)
            {
                if (this.Agents.get_Item(i).priority == priority)
                {
                    num = i;
                    break;
                }
            }
            if (num != -1 && this.Agents.get_Item(num).agents.ContainsKey(id))
            {
                this.Agents.get_Item(num).agents.Remove(id);
            }
        }
Esempio n. 7
0
        public void AddAgent(Agent pAgent)
        {
            //ASSERT_MAIN_THREAD();
            int agentId   = pAgent.GetId();
            int priority  = pAgent.GetPriority();
            int itemIndex = this.Agents.FindIndex(delegate(HeapItem_t h) { return(h.priority == priority); });

            if (itemIndex == -1)
            {
                HeapItem_t pa = new HeapItem_t();
                pa.agents          = new Dictionary <int, Agent>();
                pa.priority        = priority;
                pa.agents[agentId] = pAgent;
                this.Agents.Add(pa);
            }
            else
            {
                this.Agents[itemIndex].agents[agentId] = pAgent;
            }
        }