当前位置: 首页>>代码示例>>C#>>正文


C# PriorityQueue.TryDequeue方法代码示例

本文整理汇总了C#中System.Collections.Generic.PriorityQueue.TryDequeue方法的典型用法代码示例。如果您正苦于以下问题:C# PriorityQueue.TryDequeue方法的具体用法?C# PriorityQueue.TryDequeue怎么用?C# PriorityQueue.TryDequeue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Generic.PriorityQueue的用法示例。


在下文中一共展示了PriorityQueue.TryDequeue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendQueued

        private void SendQueued (PriorityQueue<EntityUpdate, double> m_entsqueue)
        {
            PriorityQueueItem<EntityUpdate, double> up;
            List<EntityUpdate> updates = new List<EntityUpdate> ();
            //Enqueue them all
            while (m_entsqueue.TryDequeue (out up))
            {
                updates.Add (up.Value);
            }
            //Priorities are backwards, gotta flip them around
            updates.Reverse ();
            foreach (EntityUpdate update in updates)
                QueueEntityUpdate (update);

            m_lastUpdatePos = (m_presence.IsChildAgent) ?
                m_presence.AbsolutePosition :
                m_presence.CameraPosition;
        }
开发者ID:rknop,项目名称:Aurora-Sim,代码行数:18,代码来源:SceneViewer.cs

示例2: SendQueued

        private void SendQueued (PriorityQueue<EntityUpdate, double> m_entsqueue)
        {
            PriorityQueueItem<EntityUpdate, double> up;

            //Enqueue them all
            while (m_entsqueue.TryDequeue (out up))
            {
                QueueEntityUpdate (up.Value);
            }
            m_entsqueue.Clear ();

            m_lastUpdatePos = (m_presence.IsChildAgent) ?
                m_presence.AbsolutePosition :
                m_presence.CameraPosition;
        }
开发者ID:x8ball,项目名称:Aurora-Sim,代码行数:15,代码来源:SceneViewer.cs

示例3: BestFirstSearch

        public static BooleanChain BestFirstSearch(BitSet items, long max, params BooleanChain[] chains)
        {
            PriorityQueue<double, BooleanChain> queue = new PriorityQueue<double, BooleanChain>(Comparer<double>.Default);
            foreach (BooleanChain item in chains)
            {
                if (item.MaxNeighborhoodSize <= max)
                {
                    queue.Enqueue(item.BooleanWidth * (item.Right * items).Count, item);
                }
            }

            BooleanChain chain;
            while (queue.TryDequeue(out chain))
            {
                BitSet bitSet = chain.Right * items;

                bool empty = true;
                foreach (int item in bitSet)
                {
                    empty = false;
                    BooleanChain next = new BooleanChain(chain, item);
                    if (next.MaxNeighborhoodSize <= max)
                    {
                        queue.Enqueue(next.BooleanWidth * (next.Right * items).Count, next);
                    }
                }

                if (empty)
                {
                    return chain;
                }
            }

            return null;
        }
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:35,代码来源:BooleanChain.cs

示例4: SendPrimUpdates

        /// <summary>
        /// This loops through all of the lists that we have for the client
        ///  as well as checking whether the client has ever entered the sim before
        ///  and sending the needed updates to them if they have just entered.
        /// </summary>
        public void SendPrimUpdates()
        {
            if (m_inUse)
                return;
            m_inUse = true;
            //This is for stats
            int AgentMS = Util.EnvironmentTickCount();

            #region New client entering the Scene, requires all objects in the Scene

            ///If we havn't started processing this client yet, we need to send them ALL the prims that we have in this Scene (and deal with culling as well...)
            if (!m_SentInitialObjects)
            {
                m_SentInitialObjects = true;
                //If they are not in this region, we check to make sure that we allow seeing into neighbors
                if (!m_presence.IsChildAgent || (m_presence.Scene.RegionInfo.SeeIntoThisSimFromNeighbor))
                {
                    EntityBase[] entities = m_presence.Scene.Entities.GetEntities();
                    //Use the PriorityQueue so that we can send them in the correct order
                    PriorityQueue<EntityUpdate, double> entityUpdates = new PriorityQueue<EntityUpdate, double>(entities.Length);

                    foreach (EntityBase e in entities)
                    {
                        if (e != null && e is SceneObjectGroup)
                        {
                            SceneObjectGroup grp = (SceneObjectGroup)e;

                            //Check for culling here!
                            if (!CheckForCulling(grp))
                                continue;

                            //Get the correct priority and add to the queue
                            double priority = m_prioritizer.GetUpdatePriority(m_presence.ControllingClient, grp);
                            PriorityQueueItem<EntityUpdate, double> item = new PriorityQueueItem<EntityUpdate,double>(
                                new EntityUpdate(grp, PrimUpdateFlags.FullUpdate), priority);
                            entityUpdates.Enqueue(item); //New object, send full
                        }
                    }
                    entities = null;
                    //Send all the updates to the client
                    PriorityQueueItem<EntityUpdate, double> update;
                    while (entityUpdates.TryDequeue(out update))
                    {
                        SendUpdate(PrimUpdateFlags.FullUpdate, (SceneObjectGroup)update.Value.Entity);
                    }
                }
            }

            #endregion

            #region Update loop that sends objects that have been recently added to the queue

            //Pull the parts out into a list first so that we don't lock the queue for too long
            Dictionary<UUID, List<EntityUpdate>> m_parentUpdates = new Dictionary<UUID, List<EntityUpdate>>();
            lock (m_partsUpdateQueue)
            {
                lock (m_removeNextUpdateOf)
                {
                    PriorityQueueItem<EntityUpdate, double> update;
                    while (m_partsUpdateQueue.TryDequeue(out update))
                    {
                        if (update.Value == null)
                            continue;
                        //Make sure not to send deleted or null objects
                        if (((SceneObjectPart)update.Value.Entity).ParentGroup == null || ((SceneObjectPart)update.Value.Entity).ParentGroup.IsDeleted)
                            continue;

                        //Make sure we are not supposed to remove it
                        if (m_removeNextUpdateOf.ContainsKey(update.Value.Entity.LocalId))
                        {
                            if (update.Value.Version > m_removeNextUpdateOf[update.Value.Entity.LocalId])
                            {
                                //This update is newer, let it go on by
                            }
                            else //Not newer, should be removed Note: if this is the same version, its the update we were supposed to remove... so we do NOT do >= above
                                continue;
                        }

                        //Make sure we are not supposed to remove it
                        if (m_removeUpdateOf.Contains(update.Value.Entity.LocalId))
                            continue;

                        if (!m_parentUpdates.ContainsKey(((SceneObjectPart)update.Value.Entity).ParentGroup.UUID))
                            m_parentUpdates.Add(((SceneObjectPart)update.Value.Entity).ParentGroup.UUID, new List<EntityUpdate>());

                        m_parentUpdates[((SceneObjectPart)update.Value.Entity).ParentGroup.UUID].Add(update.Value);
                    }
                    m_removeNextUpdateOf.Clear();
                }
            }

            //Now loop through the list and send the updates
            foreach (UUID ParentID in m_parentUpdates.Keys)
            {
                //Sort by LinkID
//.........这里部分代码省略.........
开发者ID:mugginsm,项目名称:Aurora-Sim,代码行数:101,代码来源:SceneViewer.cs


注:本文中的System.Collections.Generic.PriorityQueue.TryDequeue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。