Beispiel #1
0
        private bool Remove(TInput key)
        {
            bool existed = data.Remove(key);

            lruList.Remove(key);
            return(existed);
        }
Beispiel #2
0
            public void RemoveFirst()
            {
#if SALTARELLE
                index.Remove(data[0]);
                data.RemoveAt(0);
#else
                index.Remove(data.First.Value);
                data.RemoveFirst();
#endif
            }
Beispiel #3
0
        private static List <PlayerCluster> buildPlayerClusters(List <Player> players, Dictionary <Player, PlayerClusterInfo> playerClusterInformations)
        {
            JsDictionary <int, Player> hitPlayers     = players.ToDictionary(a => a.Id);
            List <PlayerCluster>       playerClusters = new List <PlayerCluster>();
            int hitPlayerCount = players.Count;


            var playerClusterInfoHits      = new JsDictionary <int, PlayerClusterInfo>();
            var playerClusterInfoHitsArray = new List <PlayerClusterInfo>();

            while (hitPlayerCount > 0)
            {
                playerClusterInfoHits.Clear();
                playerClusterInfoHitsArray.Clear();

                GetPlayerCluster(playerClusterInfoHits, playerClusterInfoHitsArray, playerClusterInformations, playerClusterInformations[hitPlayers[hitPlayers.Keys.First()]], hitPlayers);
                PlayerCluster cluster = new PlayerCluster();
                for (int index = 0; index < playerClusterInfoHitsArray.Count; index++)
                {
                    var playerClusterInfoHit = playerClusterInfoHitsArray[index];
                    cluster.Players.Add(playerClusterInfoHit.Player);
                    hitPlayers.Remove(playerClusterInfoHit.Player.Id);
                    hitPlayerCount--;
                }

                playerClusters.Add(cluster);

//                Console.WriteLine(string.Format("Players Left: {0}, Clusters Total: {1} ", hitPlayerCount, playerClusters.Count));
            }
            return(playerClusters);
        }
Beispiel #4
0
        private void condenseTree(Node <T> l)
        {
            // CT1 [Initialize] Set n=l. Set the list of eliminated
            // nodes to be empty.
            Node <T> n           = l;
            Node <T> parent      = null;
            int      parentEntry = 0;

            //TIntStack eliminatedNodeIds = new TIntStack();
            Stack <int> eliminatedNodeIds = new Stack <int>();

            // CT2 [Find parent entry] If N is the root, go to CT6. Otherwise
            // let P be the parent of N, and let En be N's entry in P
            while (n.level != treeHeight)
            {
                parent      = getNode(parents.Pop());
                parentEntry = parentsEntry.Pop();

                // CT3 [Eliminiate under-full node] If N has too few entries,
                // delete En from P and add N to the list of eliminated nodes
                if (n.entryCount < minNodeEntries)
                {
                    parent.deleteEntry(parentEntry, minNodeEntries);
                    eliminatedNodeIds.Push(n.nodeId);
                }
                else
                {
                    // CT4 [Adjust covering rectangle] If N has not been eliminated,
                    // adjust EnI to tightly contain all entries in N
                    if (!n.mbr.Equals(parent.entries[parentEntry]))
                    {
                        oldRectangle.set(parent.entries[parentEntry].min, parent.entries[parentEntry].max);
                        parent.entries[parentEntry].set(n.mbr.min, n.mbr.max);
                        parent.recalculateMBR(oldRectangle);
                    }
                }
                // CT5 [Move up one level in tree] Set N=P and repeat from CT2
                n = parent;
            }

            // CT6 [Reinsert orphaned entries] Reinsert all entries of nodes in set Q.
            // Entries from eliminated leaf nodes are reinserted in tree leaves as in
            // Insert(), but entries from higher level nodes must be placed higher in
            // the tree, so that leaves of their dependent subtrees will be on the same
            // level as leaves of the main tree
            while (eliminatedNodeIds.Count > 0)
            {
                Node <T> e = getNode(eliminatedNodeIds.Pop());
                for (int j = 0; j < e.entryCount; j++)
                {
                    add(e.entries[j], e.ids[j], e.level);
                    e.entries[j] = null;
                }
                e.entryCount = 0;
                nodeMap.Remove(e.nodeId);
                deletedNodeIds.Push(e.nodeId);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Deletes an item from the spatial index
        /// </summary>
        /// <param name="r"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool Delete(Rectangle r, T item)
        {
            int id = ItemsToIds[item];

            bool success = delete(r, id);

            if (success == true)
            {
                IdsToItems.Remove(id);
                ItemsToIds.Remove(item);
            }
            return(success);
        }
Beispiel #6
0
        private JsDictionary <string, object> GetLocalizationGridValue()
        {
            var value = new JsDictionary <string, object>();

            localizationGrid.Save(value);
            foreach (var k in value.Keys)
            {
                if (k.IndexOf('$') < 0)
                {
                    value.Remove(k);
                }
            }
            return(value);
        }
Beispiel #7
0
        public CreatedUI <T> CreateSingleton <T>(string ui, Action <T, jQueryObject> populateScope) where T : ManagedScope
        {
            T scope;

            if (singltons.ContainsKey(ui))
            {
                var html = singltons[ui];
                if (html.Parent().Length == 0)
                {
                    singltons.Remove(ui);
                }
            }

            if (singltons.ContainsKey(ui))
            {
                var html = singltons[ui];
                if (html[0].NodeType == XmlNodeType.Comment)
                {
                    singltons[ui] = html = (AngularElement)html.Next();
                }

                scope = myRootScopeService.New <T>();
                populateScope(scope, html);
                var item = myCompileService(html)(scope);
                if (scope.Phase == null)
                {
                    scope.Apply();
                }

                scope = angular.Element(item.Children()[0]).Scope <T>() ?? scope;
                return(new CreatedUI <T>(scope, html));
            }
            else
            {
                scope = myRootScopeService.New <T>();
                var html = jQuery.FromHtml(string.Format("<div ng-include src=\"'{1}partials/UIs/{0}.html'\"></div>", ui, Constants.ContentAddress));
                populateScope(scope, html);
                var item = myCompileService(html)(scope);
                item.AppendTo(Window.Document.Body);
                if (scope.Phase == null)
                {
                    scope.Apply();
                }

                scope         = angular.Element(item.Children()[0]).Scope <T>() ?? scope;
                singltons[ui] = item;

                return(new CreatedUI <T>(scope, item));
            }
        }
Beispiel #8
0
        private void SaveClick()
        {
            if (pendingChanges.Count == 0)
            {
                return;
            }

            // this calls save service for all modified rows, one by one
            // you could write a batch update service

            var enumerator = Q.DeepClone(pendingChanges).GetEnumerator();

            Action saveNext = null;

            saveNext = delegate()
            {
                if (!enumerator.MoveNext())
                {
                    Refresh();
                    return;
                }

                var pair   = enumerator.Current;
                var entity = Q.DeepClone(pair.Value);
                entity.ProductID = pair.Key;
                ProductService.Update(new SaveRequest <ProductRow>
                {
                    EntityId = pair.Key,
                    Entity   = entity
                }, response =>
                {
                    pendingChanges.Remove(pair.Key);
                    saveNext();
                });
            };

            saveNext();
        }
Beispiel #9
0
        public GridRowSelectionMixin(IDataGrid grid)
        {
            this.grid    = grid;
            this.idField = grid.GetView().IdField;

            grid.GetGrid().OnClick.Subscribe((e, p) => {
                if (J(e.Target).HasClass("select-item"))
                {
                    e.PreventDefault();

                    var item = grid.GetView().GetItem(p.row);
                    var id   = item[idField].toString();

                    if (include.ContainsKey(id))
                    {
                        include.Remove(id);
                    }
                    else
                    {
                        include[id] = true;
                    }

                    for (var i = 0; i < grid.GetView().GetLength(); i++)
                    {
                        grid.GetGrid().UpdateRow(i);
                    }

                    UpdateSelectAll();
                }
            });

            grid.GetGrid().OnHeaderClick.Subscribe((e, u) =>
            {
                if (e.IsDefaultPrevented())
                {
                    return;
                }

                if (J(e.Target).HasClass("select-all-items"))
                {
                    e.PreventDefault();
                    var view = grid.GetView();

                    if (include.Count > 0)
                    {
                        include.Clear();
                    }
                    else
                    {
                        foreach (var x in grid.GetView().GetItems())
                        {
                            var id = x[idField];
                            include[id.toString()] = true;
                        }
                    }
                    UpdateSelectAll();
                    grid.GetView().SetItems(grid.GetView().GetItems(), true);
                }
            });

            grid.GetView().OnRowsChanged.Subscribe((e, u) => UpdateSelectAll());
        }