コード例 #1
0
        private static void ApplyFilters(NetworkContext ctx, Dictionary <Network, IReadOnlyList <AssetPair> > pbn)
        {
            if (ctx.OnlyNetworks?.Any() != true)
            {
                pbn.RemoveAll(x => ctx.BadNetworks.Contains(x.Key));
            }
            else
            {
                pbn.RemoveAll(x => !ctx.OnlyNetworks.Contains(x.Key));
            }

            if (ctx.OnlyPairs?.Any() != true)
            {
                var clone = pbn.ToDictionary(x => x.Key, y => y.Value);
                foreach (var kv in clone)
                {
                    pbn[kv.Key] = new AssetPairs(kv.Value.Where(p => !ctx.BadCoins.Contains(p.Asset1) && !ctx.BadCoins.Contains(p.Asset2)));
                }
            }
            else
            {
                ApplyOnlyPairs(ctx, pbn);
            }

            RemoveFaulting(pbn);
        }
コード例 #2
0
        static internal void ClearExpired()
        {
            //TODO: dispose objects ?
            int count1 = AllByPawnPair.Count();
            int count2 = AllByPawnPair.RemoveAll(arg => arg.Value.Expired());

#if DEBUG
            Log.Message(string.Format("Cleared {0}/{1} expired cache items", count2, count1));
#endif
        }
コード例 #3
0
 public override void ExposeData()
 {
     if (Scribe.mode == LoadSaveMode.Saving)
     {
         assignedHives.RemoveAll((KeyValuePair <Pawn, Hive> x) => x.Key.Destroyed);
     }
     Scribe_Collections.Look(ref assignedHives, "assignedHives", LookMode.Reference, LookMode.Reference);
     if (Scribe.mode == LoadSaveMode.PostLoadInit)
     {
         assignedHives.RemoveAll((KeyValuePair <Pawn, Hive> x) => x.Value == null);
     }
 }
コード例 #4
0
 public void RemoveDestroyedPawn(Pawn key)
 {
     forcedJobs.RemoveAll(x => x.Key == key);
     madSurgeonsWithLastHarvestedTick.RemoveAll(x => x.Key == key);
     wanderLustersWithLastMapExitedTick.RemoveAll(x => x.Key == key);
     perfectionistsWithJobsToStop.RemoveWhere(x => x == key);
     cowards.RemoveWhere(x => x == key);
     snobs.RemoveWhere(x => x == key);
     bigBoned.RemoveWhere(x => x == key);
     squeamishWithLastVomitedTick.RemoveAll(x => x.Key == key);
     absentMindedWithLastDiscardedTick.RemoveAll(x => x.Key == key);
 }
コード例 #5
0
        public void RemoveAll_Collection_NotFound()
        {
            var collection = new Dictionary<int, int> { { 1, 1 }, { 3, 3 }, { 5, 3 } };
            Assert.IsFalse (collection.RemoveAll (kvp => kvp.Value == 2));

            Assert.AreEqual (3, collection.Count);
        }
コード例 #6
0
        internal static void Update()
        {
            lock (Timers)
            {
                var readonlyTimers = Timers.Values.ToList();
                var toRemove       = new List <TimerInfo>();

                foreach (var timer in readonlyTimers)
                {
                    timer.Time -= GameOptions.Timestep;

                    if (timer.Time > 0)
                    {
                        continue;
                    }

                    if (timer.Event())
                    {
                        toRemove.Add(timer);
                    }
                    else
                    {
                        timer.Time = timer.StartTime;
                    }
                }

                Timers.RemoveAll(kv => toRemove.Contains(kv.Value));
            }
        }
コード例 #7
0
    protected void RemoveWorseAttacks(ref Dictionary <Vector2Int, Piece> locations, List <Vector2Int> attackAble)
    {
        Dictionary <Vector2Int, float> greatAttackPoints = new Dictionary <Vector2Int, float>();

        Vector2Int[] afterMovePosition;

        for (int i = 0; i < attackAble.Count; i++)
        {
            // get position of enemies at new position.
            afterMovePosition = GetPositionsWithEnemies(GetCombinedDirections(), attackAble[i]).ToArray();

            if (afterMovePosition.Length <= 0)
            {
                greatAttackPoints.Add(attackAble[i], 1);
            }

            else
            {
                if (!greatAttackPoints.ContainsKey(attackAble[i]))
                {
                    greatAttackPoints.Add(attackAble[i], afterMovePosition.Length);
                    attackAble.Add(attackAble[i]);
                }
            }
        }

        Vector2Int finalPosition = greatAttackPoints.Aggregate((x, y) => x.Value > y.Value ? x : y).Key;

        locations.RemoveAll((key, value) => key != finalPosition);
    }
コード例 #8
0
 private void RemoveMoveIfCanAttack(Dictionary <Vector2Int, Piece> locations)
 {
     if (locations.Values.Any(value => value != null))
     {
         locations.RemoveAll((key, value) => value == null);
     }
 }
コード例 #9
0
ファイル: EntityManager.cs プロジェクト: Rohansi/Californium
        public void Update()
        {
            var newGridPos = new Vector2i();

            var cur = entities.First;

            while (cur != null)
            {
                var next = cur.Next;
                var e    = cur.Value;

                currentEntity = e;
                e.Update();
                currentEntity = null;

                newGridPos.X = (int)e.Position.X / GameOptions.EntityGridSize;
                newGridPos.Y = (int)e.Position.Y / GameOptions.EntityGridSize;

                if (!e.GridCoordinate.Equals(newGridPos) && GridRemove(e))
                {
                    e.GridCoordinate = newGridPos;
                    GridAdd(e);
                }

                cur = next;
            }

            cleanupTimer += GameOptions.Timestep;
            if (cleanupTimer >= CleanupEvery)
            {
                entityGrid.RemoveAll(kv => kv.Value.Count == 0);
                cleanupTimer = 0;
            }
        }
コード例 #10
0
 public void TrackerTick()
 {
     TargetsDone.RemoveAll(t => t.Key == null);
     trackedPawns.RemoveAll(t => !t.Spawned);
     trackedThings.RemoveAll(t => !t.Spawned);
     CurrentlyOwnedTargets.RemoveAll(t => !t.Key.Spawned);
 }
コード例 #11
0
        public void Delete(Int32 position)
        {
            int wsCount = _worksheets.Values.Count(w => w.Position == position);

            if (wsCount == 0)
            {
                throw new ArgumentException("There isn't a worksheet associated with that index.");
            }

            if (wsCount > 1)
            {
                throw new ArgumentException(
                          "Can't delete the worksheet because there are multiple worksheets associated with that index.");
            }

            var ws = _worksheets.Values.Single(w => w.Position == position);

            if (!String.IsNullOrWhiteSpace(ws.RelId) && !Deleted.Contains(ws.RelId))
            {
                Deleted.Add(ws.RelId);
            }

            _worksheets.RemoveAll(w => w.Position == position);
            _worksheets.Values.Where(w => w.Position > position).ForEach(w => w._position         -= 1);
            _workbook.UnsupportedSheets.Where(w => w.Position > position).ForEach(w => w.Position -= 1);
        }
コード例 #12
0
        public static bool RemoveRule(string selectorId)
        {
            if (selectorId == null)
            {
                return(false);
            }

            try {
                rwl.AcquireWriterLock(monitorTimeout);
                try {
                    PawnSelector ps = new PawnSelector(selectorId, null, null);
                    ruleset.Remove(ps);
                    foreach (KeyValuePair <string, Dictionary <PawnSelector, IEnumerable <ThingDef> > > p in lookupRulesetViaIntent)
                    {
                        p.Value.Remove(ps);
                    }
                    lookupRulesetViaIntent.RemoveAll(p => p.Value.Count <= 0);
                    return(true);
                } finally {
                    rwl.ReleaseWriterLock();
                }
            } catch (ApplicationException) { }

            return(false);
        }
コード例 #13
0
        public void AddPatch(Span <byte> data, long offset)
        {
            Range dataRange = new Range(offset, offset + data.Length);
            IEnumerable <Range> overlapping = Patches.Keys.Overlapping(dataRange).OrderByDescending(r => r.Length);

            if (overlapping.Any()) // if the data overlaps with an existing patch, we need to merge it
            {
                Range  mergedRange = new Range(overlapping.Min(r => r.Start), overlapping.Max(r => r.End));
                byte[] mergedData  = new byte[mergedRange.Length];

                // copy data into new range (largest to smallest)
                foreach (Range r in overlapping.Concat(new Range[] { dataRange }))
                {
                    byte[] iData = Patches[r];
                    Array.Copy(iData, 0, mergedData, r.Start - mergedRange.Start, iData.Length);
                }

                Patches.RemoveAll(overlapping);
                Patches[mergedRange] = mergedData;
            }
            else
            {
                Patches[dataRange] = data.ToArray();
            }
        }
コード例 #14
0
        /// <summary>
        /// Makes sure the number of events stored doesnt get too large.
        /// </summary>
        private static void ClearEvents()
        {
            var cutoff = DateTime.UtcNow - TimeSpan.FromSeconds(2);

            if (_lastClearedEvents > cutoff)
            {
                return;
            }

            var beforeCount = Events.Count;

            lock (Synchronizer)
            {
                Events.RemoveWhere(e => e.Time < cutoff);
                _lastClearedEvents = DateTime.UtcNow;
            }

            _hasFiredIds.RemoveAll(e => DateTime.UtcNow.Subtract(e.Value).TotalSeconds > 10);
            _lastClearedEvents = DateTime.UtcNow;

            if (Settings.Misc.DebugLogging)
            {
                Log.Debug("Cleared Events Cache Before={0} After={1}", beforeCount, Events.Count);
            }
        }
コード例 #15
0
        public override void FinalizeInit()
        {
            holdingSettingList.RemoveAll(list => !(Verse.Find.VisibleMap.thingGrid.ThingAt <Blueprint_Build>(list.Key) != null ||
                                                   Verse.Find.VisibleMap.thingGrid.ThingAt <Frame>(list.Key) != null));

            base.FinalizeInit();
        }
コード例 #16
0
 public static void KillDynamic()
 {
     TileList.RemoveAll(tile => tile.IsLoaded);
     GuidLookup.RemoveAll(pair => pair.Value.IsLoaded);
     NameLookup.RemoveAll(pair => pair.Value.IsLoaded);
     PathLookup.RemoveAll(pair => pair.Value.IsLoaded);
 }
コード例 #17
0
        private static void RemoveFaulting(Dictionary <Network, IReadOnlyList <AssetPair> > pbn)
        {
            var hasFault = false;

            var networks = pbn.Keys.ToList();

            foreach (var n in networks)
            {
                var prov = n.Providers.FirstOf <IDepositProvider>();
                if (prov == null)
                {
                    continue;
                }

                var r = ApiCoordinator.GetTransferSuspensions(prov);
                if (r.IsNull)
                {
                    continue;
                }

                var pairs = pbn[n].AsList();
                var c     = pairs.Count;
                pairs.RemoveAll(x => r.Response.DepositSuspended.Any(x.Has));
                pairs.RemoveAll(x => r.Response.WithdrawalSuspended.Any(x.Has));
                hasFault = hasFault || c != pairs.Count;

                pbn[n] = pairs;
            }

            if (hasFault)
            {
                pbn.RemoveAll(x => !x.Value.Any());
            }
        }
コード例 #18
0
    public void UnloadLevelsOfType(LevelType type)
    {
        var removals     = LoadedLocalLevels.RemoveAll(level => level.Type == type);
        var removedPaths = removals.Select(it => it.Item2.Path).ToHashSet();

        loadedPaths.RemoveWhere(it => removedPaths.Contains(it));
    }
コード例 #19
0
        public override void ExposeData()
        {
            base.ExposeData();

            Scribe_Collections.Look(ref Configvalues, "TA_Expose_Numbers", LookMode.Value, LookMode.Value);
            int isPplDictSaved = 1;

            //LogOutput.WriteLogMessage(Errorlevel.Information, "val:" + isPplDictSaved.ToString());
            Scribe_Values.Look(ref isPplDictSaved, "TA_Expose_People_isSaved", -1, true);
            //LogOutput.WriteLogMessage(Errorlevel.Information, "val:" + isPplDictSaved.ToString());
            if (ColonyPeople != null)
            {
                ColonyPeople.RemoveAll(x => x.Key == null);
            }
            if (isPplDictSaved == 1)
            {
                Scribe_Collections.Look(ref ColonyPeople, "TA_Expose_People", LookMode.Reference, LookMode.Reference);
                //LogOutput.WriteLogMessage(Errorlevel.Information, "Read TA_ExposePeople");
            }
            //TechAdvancing_Config_Tab.ExposeData(TA_Expose_Mode.Load);
            if (ColonyPeople == null)
            {
                ColonyPeople = new Dictionary <Pawn, Faction>();
            }
        }
コード例 #20
0
 private void ClearGateDestination()
 {
     _deathGate         = null;
     _deathGatePosition = Vector3.Zero;
     _deathGateIgnoreList.RemoveAll(dt => DateTime.UtcNow.Subtract(dt).TotalMinutes > 5);
     _interactionCoroutine = null;
 }
コード例 #21
0
        public void SetRandomHash(Hash bestChainBlockHash, Hash randomHash)
        {
            _randomHashes.RemoveAll(p => !_blockHashes.Values.Contains(p.Key));
            _randomHashes[bestChainBlockHash] = randomHash;

            {
                var log = new StringBuilder("\n");
                foreach (var hashLink in _blockHashes)
                {
                    log.Append($"{hashLink.Key} - {hashLink.Value.ToHex()}\n");
                }

                Logger.LogTrace($"Block hash links:{log}");
            }

            {
                var log = new StringBuilder("\n");
                foreach (var hashLink in _randomHashes)
                {
                    log.Append($"{hashLink.Key} - {hashLink.Value.ToHex()}\n");
                }

                Logger.LogTrace($"Random hash links:{log}");
            }
        }
コード例 #22
0
        public void RemoveAllTest()
        {
            var d = new Dictionary <int, string>(_dict);

            d.RemoveAll(i => i >= 1);
            Assert.That(d.Count == 1);
        }
コード例 #23
0
        public static IList <Facet> ToFacets(this NameValueCollection target)
        {
            var parameters = new Dictionary <string, string>();

            foreach (var queryString in HttpContext.Current.Request.QueryString.AllKeys)
            {
                parameters[queryString] = HttpContext.Current.Request.QueryString[queryString];
            }

            parameters.RemoveAll(kvp =>
                                 new [] { "umbDebugShowTrace", "product", "variant", "category", "categories", "catalog" }
                                 .Contains(kvp.Key));

            var facetsForQuerying = new List <Facet>();

            foreach (var parameter in parameters)
            {
                var facet = new Facet {
                    FacetValues = new List <FacetValue>(), Name = parameter.Key
                };
                foreach (var value in parameter.Value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    facet.FacetValues.Add(new FacetValue()
                    {
                        Value = value
                    });
                }

                facetsForQuerying.Add(facet);
            }

            return(facetsForQuerying);
        }
コード例 #24
0
            public List <IntVec3> Unobstructed(IntVec3 motivator, bool removed = false)
            {
                //1. What is the test is?
                bool     lazy      = motivator == IntVec3.Zero;
                cellTest motivated = (target, inside) => target == motivator ? removed : IsClear(target, inside);
                cellTest clear     = lazy ? IsClear : motivated;

                //2. Determine facing
                IntVec3 dummy;
                bool    overhangFwd = !ClearForward(position, horizontal, clear, false, 1, out dummy);  //sets facing Down/Left
                bool    overhangBwd = !ClearBackward(position, horizontal, clear, false, 1, out dummy); //sets facing Up/Right

                facingSet = SetFacing(overhangFwd, overhangBwd);
                if (!facingSet)
                {
                    return(new List <IntVec3>());           //escape if unable to determine sides
                }
                bool southward = facing == LinkDirections.Down || facing == LinkDirections.Left;

                //3. Determine clearence and max reach on each side
                Dictionary <IntVec3, int> cleared = new Dictionary <IntVec3, int>();
                int reachFwd = 0;
                int reachBwd = 0;

                //forward (walks North/East)
                for (int i = 1; i <= maxreach; i++)
                {
                    IntVec3 clearedFwd;
                    if (ClearForward(position, horizontal, clear, southward, i, out clearedFwd))
                    {
                        cleared.Add(clearedFwd, i);
                        reachFwd++;
                    }
                    else
                    {
                        break;
                    }
                }
                //backward (walks South/West)
                for (int i = 1; i <= maxreach; i++)
                {
                    IntVec3 clearedBwd;
                    if (ClearBackward(position, horizontal, clear, !southward, i, out clearedBwd))
                    {
                        cleared.Add(clearedBwd, i);
                        reachBwd++;
                    }
                    else
                    {
                        break;
                    }
                }

                //5. Apply clearance.
                int obstructed = southward ? reachBwd : reachFwd;

                cleared.RemoveAll(x => x.Key.IsInterior(position, facing) && x.Value > obstructed);
                return(cleared.Keys.ToList());
            }
コード例 #25
0
        public void RemoveAll_empty()
        {
            var dictionary = new Dictionary <string, int>();

            dictionary.RemoveAll(value => value == 2);

            Assert.Empty(dictionary);
        }
コード例 #26
0
ファイル: CollectionCodaTests.cs プロジェクト: rikkus/cadenza
        public void RemoveAll_MultipleCollection()
        {
            var collection = new Dictionary<int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 }, { 4, 2 }, { 5, 3 } };
            collection.RemoveAll (kvp => kvp.Value == 2);

            Assert.AreEqual (3, collection.Count);
            Assert.IsFalse (collection.ContainsValue (2), "Collection still contains removed items");
        }
コード例 #27
0
 public override void ExposeData()
 {
     if (Scribe.mode == LoadSaveMode.Saving)
     {
         presentForTicks.RemoveAll((KeyValuePair <Pawn, int> x) => x.Key.Destroyed);
     }
     Scribe_Collections.Look(ref presentForTicks, "presentForTicks", LookMode.Reference);
 }
コード例 #28
0
 internal IEnumerable <ServiceInstance> RemoveNotActivated()
 {
     _requestsBySignature.RemoveAll(k => k.Value.SchedulingInfo.SchedulingStatus != SchedulingStatus.Activated);
     foreach (var request in _requestsByGuid.RemoveAll(k => k.Value.SchedulingInfo.SchedulingStatus != SchedulingStatus.Activated))
     {
         yield return(request.Value);
     }
 }
コード例 #29
0
    /// <summary>
    /// 任意の位置に爆弾が配置可能かどうかを返します
    /// </summary>
    /// <returns><c>true</c> if this instance is bom puttable the specified position; otherwise, <c>false</c>.</returns>
    /// <param name="position">Position.</param>
    public bool IsBomPuttable(Vector3 position)
    {
        boms.RemoveAll((k, v) => null == v);

        var coordinate = Main_SceneController.Instance.PositionToCoordinate(position);

        return(!boms.ContainsKey(coordinate) && !walls.ContainsKey(coordinate));
    }
コード例 #30
0
        public void RemoveAll(Func<XLRow, Boolean> predicate)
        {
            foreach (XLRow kp in _dictionary.Values.Where(predicate).Select(c => c).Where(kp => !_deleted.ContainsKey(kp.RowNumber())))
            {
                _deleted.Add(kp.RowNumber(), kp);
            }

            _dictionary.RemoveAll(predicate);
        }
コード例 #31
0
        public void RemoveAll(Func <XLRow, Boolean> predicate)
        {
            foreach (var row in _dictionary.Values.Where(predicate).Where(row1 => !Deleted.ContainsKey(row1.RowNumber())))
            {
                Deleted.Add(row.RowNumber(), row);
            }

            _dictionary.RemoveAll(predicate);
        }
コード例 #32
0
 void MainForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (sender is MainForm mainForm)
     {
         mainForm.FormClosed -= MainForm_FormClosed;
         mainForm.ReferenceEditorFilterSet.Filters.CollectionChanged -= Filters_CollectionChanged;
         filters.RemoveAll(pair => pair.Value.Equals(mainForm));
     }
 }
コード例 #33
0
ファイル: TextUtilities.cs プロジェクト: Glain/FFTPatcher
        public static IDictionary<string, int> GetPairAndTripleCounts( string text, Set<string> allowedGroups )
        {
            Dictionary<string, int> counts = new Dictionary<string, int>();
            text = text.Replace( "\r\n", "{}" );
            int length = text.Length;

            Action<int> meth =
                delegate( int groupSize )
                {
                    for ( int pos = 0; pos + groupSize - 1 < length; )
                    {
                        for ( int j = 1; j < groupSize; j++ )
                        {
                            if ( text[pos + j] == '{' )
                            {
                                pos++;
                            }
                        }
                        while ( pos < length && text[pos] == '{' )
                        {
                            while ( text[++pos] != '}' )
                                ;
                            pos++;
                        }

                        if ( pos + groupSize - 1 < length )
                        {
                            IncrementPairCount( text.Substring( pos, groupSize ), counts );
                        }
                        pos++;
                    }
                };

            meth( 2 );

            counts.RemoveAll( p => !allowedGroups.Contains( p ) );
            return counts;
        }