System.Collections.Generic.Dictionary.Remove(int)

Here are the examples of the csharp api System.Collections.Generic.Dictionary.Remove(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1287 Examples 7

19 View Source File : MemcachedProcess.cs
License : MIT License
Project Creator : 0ffffffffh

private static void Process_Exited(object sender, EventArgs e)
        {
            MemcachedProcess mp;
            Process process = sender as Process;

            Log.Error("memcached process {0} had lost with {1} code",
                process.Id, process.ExitCode);

            if (_Processes.TryGetValue(process.Id, out mp))
            {
                if (mp.Exited != null)
                {
                    Log.Info("Calling memcached process's exit event");
                    mp.Exited(mp, null);
                }

                Log.Info("removing instance from the mc proc list");

                _Processes.Remove(process.Id);
            }

            //register new instance search
        }

19 View Source File : MemcachedProcess.cs
License : MIT License
Project Creator : 0ffffffffh

public bool Kill()
        {
            this.process.Kill();
            this.process.WaitForExit(5000);

            if (this.process.HasExited)
            {
                if (_Processes.ContainsKey(this.process.Id))
                    _Processes.Remove(this.process.Id);

                return true;
            }

            return false;
        }

19 View Source File : PhotonParser.cs
License : MIT License
Project Creator : 0blu

private void HandleSegmentedPayload(int startSequenceNumber, int totalLength, int fragmentLength, int fragmentOffset, byte[] source, ref int offset)
        {
            SegmentedPackage segmentedPackage = GetSegmentedPackage(startSequenceNumber, totalLength);

            Buffer.BlockCopy(source, offset, segmentedPackage.TotalPayload, fragmentOffset, fragmentLength);
            offset += fragmentLength;
            segmentedPackage.BytesWritten += fragmentLength;

            if (segmentedPackage.BytesWritten >= segmentedPackage.TotalLength)
            {
                _pendingSegments.Remove(startSequenceNumber);
                HandleFinishedSegmentedPackage(segmentedPackage.TotalPayload);
            }
        }

19 View Source File : StringDedupeContext.cs
License : MIT License
Project Creator : 0x0ade

public void Count(int value) {
            if (Map.ContainsKey(value))
                return;

            if (!Counting.TryGetValue(value, out int count))
                count = 0;
            if (++count >= PromotionCount) {
                Counting.Remove(value);
                Map[value] = new();
            } else {
                Counting[value] = count;
            }

            if (Counting.Count >= MaxCounting)
                Cleanup();
        }

19 View Source File : StringDedupeContext.cs
License : MIT License
Project Creator : 0x0ade

public void Cleanup() {
            foreach (KeyValuePair<int, int> entry in Counting) {
                int score = entry.Value - DemotionScore;
                if (score <= 0) {
                    CountingUpdates.Add(ToCountingUpdate(entry.Key, 0));
                } else if (score >= PromotionTreshold) {
                    CountingUpdates.Add(ToCountingUpdate(entry.Key, 0));
                    Map[entry.Key] = new();
                } else {
                    CountingUpdates.Add(ToCountingUpdate(entry.Key, score));
                }
            }
            foreach (ulong update in CountingUpdates) {
                FromCountingUpdate(update, out int key, out int value);
                if (value == 0)
                    Counting.Remove(key);
                else
                    Counting[key] = value;
            }
            CountingUpdates.Clear();
        }

19 View Source File : Client.cs
License : MIT License
Project Creator : 1ZouLTReX1

private void RenderServerTick(List<PlayerState> playerStates, List<RayState> rayStates)
    {
        // Every time we encounter an ID when we set the state we remove it from this hashset and then 
        // disconnect all the players that left in the hashset.
        HashSet<int> DisconnectedPlayersIds = new HashSet<int>(PlayerFromId.Keys);

        foreach (PlayerState ps in playerStates)
        {
            // Since we got the id in the players state this ps.Id client is still connected thus we remove it from the hashset.
            DisconnectedPlayersIds.Remove(ps.playerId);

            if (PlayerFromId.ContainsKey(ps.playerId))
            {
                // Update Scene from the new given State
                PlayerFromId[ps.playerId].FromState(ps);
            }
            else
            {
                var obj = Instantiate(playerPrefab, Vector3.zero, Quaternion.idenreplacedy);
                var tmpPlayer = obj.GetComponent<Player>();
                tmpPlayer.SetPlayerID(ps.playerId);
                // The replicated gameobjects shouldn't be simulated
                tmpPlayer.rb.simulated = false;

                tmpPlayer.FromState(ps);
                PlayerFromId.Add(ps.playerId, tmpPlayer);
            }
        }

        foreach (RayState rs in rayStates)
        {
            PlayerFromId[rs.owner].FromState(rs);
        }

        // Only the clients that were in the hashset beforehand but got removed is here 
        // (since they are disconnected they are no longer in the snapshots).
        foreach (int playerId in DisconnectedPlayersIds)
        {
            if (playerId == myID)
            {
                Application.Quit();
            }

            Destroy(PlayerFromId[playerId].playerContainer);
            PlayerFromId.Remove(playerId);
        }
    }

19 View Source File : LeapHandController.cs
License : MIT License
Project Creator : 39M

protected virtual void UpdateHandRepresentations(Dictionary<int, HandRepresentation> all_hand_reps, ModelType modelType, Frame frame) {
      for (int i = 0; i < frame.Hands.Count; i++) {
        var curHand = frame.Hands[i];
        HandRepresentation rep;
        if (!all_hand_reps.TryGetValue(curHand.Id, out rep)) {
          rep = factory.MakeHandRepresentation(curHand, modelType);
          if (rep != null) {
            all_hand_reps.Add(curHand.Id, rep);
          }
        }
        if (rep != null) {
          rep.IsMarked = true;
          rep.UpdateRepresentation(curHand);
          rep.LastUpdatedTime = (int)frame.Timestamp;
        }
      }

      /** Mark-and-sweep to finish unused HandRepresentations */
      HandRepresentation toBeDeleted = null;
      for (var it = all_hand_reps.GetEnumerator(); it.MoveNext();) {
        var r = it.Current;
        if (r.Value != null) {
          if (r.Value.IsMarked) {
            r.Value.IsMarked = false;
          } else {
            /** Initialize toBeDeleted with a value to be deleted */
            //Debug.Log("Finishing");
            toBeDeleted = r.Value;
          }
        }
      }
      /**Inform the representation that we will no longer be giving it any hand updates 
       * because the corresponding hand has gone away */
      if (toBeDeleted != null) {
        all_hand_reps.Remove(toBeDeleted.HandID);
        toBeDeleted.Finish();
      }
    }

19 View Source File : ConnectionManager.cs
License : MIT License
Project Creator : a11s

internal void CheckTimeout()
        {
            RemoveCloseRequests();
            foreach (var item in ConnDict)
            {
                var t = DateTime.Now.Subtract(item.Value.LastPackTime);
                if (t > _connectionTimeout)
                {
                    RecycleSession(item.Key);//归还
                    try
                    {
                        item.Value.OnTimeout(item.Value.LastPackTime, t);
                        //Console.WriteLine($"peer {item.Value.Context.SessionId} [email protected]{item.Value.LastPackTime}" );

                    }
                    catch (Exception ex)
                    {
                        log($"sid:{item.Key}, {ex}");
                    }
                    if (removelist == null)
                    {
                        removelist = new List<int>();
                    }
                    removelist.Add(item.Key);

                }
                else
                {
                    //让Peer处理消息
                    item.Value.UpdateInternal();
                }
            }
            if (removelist != null)
            {
                foreach (var item in removelist)
                {
                    ConnDict.Remove(item);
                }
                removelist.Clear();
                removelist = null;
            }
        }

19 View Source File : LayersManagerInspector.Drawers.cs
License : MIT License
Project Creator : a3geek

private void DrawPhysicsLayers(Dictionary<int, string> layers)
        {
            EditorGUI.indentLevel += 1;

            using(var vert = new EditorGUILayout.VerticalScope())
            {
                using(var hori = new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.PrefixLabel("Size");

                    var count = EditorGUILayout.DelayedIntField(layers.Count);
                    layers.SetCount(count, index => index + LayersManager.UnityLayerCount, index => "PhysicsLayer" + index);
                }

                EditorGUILayout.Space();

                var layerIDs = new List<int>(layers.Keys);
                foreach(var layerID in layerIDs)
                {
                    using(var hori = new EditorGUILayout.HorizontalScope())
                    {
                        var layerName = layers[layerID];

                        EditorGUILayout.PrefixLabel("Layer ID : " + layerID);
                        layers[layerID] = EditorGUILayout.DelayedTextField(layerName);

                        if(string.IsNullOrEmpty(layers[layerID]) == true)
                        {
                            layers[layerID] = layerName;
                        }
                        
                        if(GUILayout.Button("Delete"))
                        {
                            layers.Remove(layerID);
                        }
                    }
                }
            }

            EditorGUI.indentLevel -= 1;
        }

19 View Source File : UMAData.cs
License : Apache License 2.0
Project Creator : A7ocin

public void RemoveDna(int dnaTypeNameHash)
			{
				dnaValues.Remove(umaDna[dnaTypeNameHash]);
				umaDna.Remove(dnaTypeNameHash);
			}

19 View Source File : UMAData.cs
License : Apache License 2.0
Project Creator : A7ocin

public void RemoveDna(Type type)
			{
				int dnaTypeNameHash = UMAUtils.StringToHash(type.Name);
				dnaValues.Remove(umaDna[dnaTypeNameHash]);
				umaDna.Remove(dnaTypeNameHash);
			}

19 View Source File : UMASkeleton.cs
License : Apache License 2.0
Project Creator : A7ocin

public virtual void RemoveBone(int nameHash)
		{
			BoneData bd = GetBone(nameHash);
			if (bd != null)
			{
				boneHashData.Remove(nameHash);
#if UNITY_EDITOR
				boneHashDataBackup.Remove(bd);
#endif
			}
		}

19 View Source File : UnityTouchDeviceManager.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

private void RemoveTouchController(Touch touch)
        {
            using (RemoveTouchControllerPerfMarker.Auto())
            {
                UnityTouchController controller;

                if (!ActiveTouches.TryGetValue(touch.fingerId, out controller))
                {
                    return;
                }

                RecyclePointers(controller.InputSource);

                controller.TouchData = touch;
                controller.EndTouch();
                // Schedule the source lost event.
                touchesToRemove.Add(controller);
                // Remove from the active collection
                ActiveTouches.Remove(touch.fingerId);
            }
        }

19 View Source File : MixedRealityInputModule.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

void IMixedRealitySourceStateHandler.OnSourceLost(SourceStateEventData eventData)
        {
            using (OnSourceLostPerfMarker.Auto())
            {
                var inputSource = eventData.InputSource;

                for (int i = 0; i < inputSource.Pointers.Length; i++)
                {
                    var pointer = inputSource.Pointers[i];
                    if (pointer.InputSourceParent == inputSource)
                    {
                        int pointerId = (int)pointer.PointerId;
                        Debug.replacedert(pointerDataToUpdate.ContainsKey(pointerId));

                        PointerData pointerData = null;
                        if (pointerDataToUpdate.TryGetValue(pointerId, out pointerData))
                        {
                            Debug.replacedert(!pointerDataToRemove.Contains(pointerData));
                            pointerDataToRemove.Add(pointerData);

                            pointerDataToUpdate.Remove(pointerId);
                        }
                    }
                }
            }
        }

19 View Source File : P2PManager.cs
License : MIT License
Project Creator : absurd-joy

public void RemoveNetworkBall(GameObject ball)
		{
			m_localBalls.Remove(ball.GetInstanceID());
		}

19 View Source File : OvrAvatarTextureCopyManager.cs
License : MIT License
Project Creator : absurd-joy

private IEnumerator DeleteTextureSetCoroutine(TextureSet textureSetToDelete, int gameobjectID)
    {
        // Wait a conservative amount of time for gpu upload to finish. Unity 2017 doesn't support async GPU calls,
        // so this 10 second time is a very conservative delay for this process to occur, which should be <1 sec.
        yield return new WaitForSeconds(GPU_TEXTURE_COPY_WAIT_TIME);

        // Spin if an avatar is loading
        while (OvrAvatarSDKManager.Instance.IsAvatarLoading())
        {
            yield return null;
        }

        // The avatar's texture set is compared against all other loaded or loading avatar texture sets.
        foreach (var textureIdAndSingleMeshFlag in textureSetToDelete.TextureIDSingleMeshPair)
        {
            bool triggerDelete = !textureIdAndSingleMeshFlag.Value;
            if (triggerDelete)
            {
                foreach (KeyValuePair<int, TextureSet> textureSet in textureSets)
                {
                    if (textureSet.Key == gameobjectID)
                    {
                        continue;
                    }

                    foreach (var comparisonTextureIDSingleMeshPair in textureSet.Value.TextureIDSingleMeshPair)
                    {
                        // Mark the texture as not deletable if it's present in another set and that set hasn't been processed
                        // or that texture ID is marked as part of a single mesh component.
                        if (comparisonTextureIDSingleMeshPair.Key == textureIdAndSingleMeshFlag.Key &&
                            (!textureSet.Value.IsProcessed || comparisonTextureIDSingleMeshPair.Value))
                        {
                            triggerDelete = false;
                            break;
                        }
                    }

                    if (!triggerDelete)
                    {
                        break;
                    }
                }
            }

            if (triggerDelete)
            {
                Texture2D textureToDelete = OvrAvatarComponent.GetLoadedTexture(textureIdAndSingleMeshFlag.Key);
                if (textureToDelete != null)
                {
                    AvatarLogger.Log("Deleting texture " + textureIdAndSingleMeshFlag.Key);
                    OvrAvatarSDKManager.Instance.DeletereplacedetFromCache(textureIdAndSingleMeshFlag.Key);
                    Destroy(textureToDelete);
                }
            }
        }
        textureSetToDelete.IsProcessed = true;
        textureSets.Remove(gameobjectID);
    }

19 View Source File : ParticleManager.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void UpdateParticles()
        {
            var remove = new List<int>();

            foreach (var emitter in ParticleTable)
            {
                if (!emitter.Value.UpdateParticles())
                    remove.Add(emitter.Key);
            }

            foreach (var emitter in remove)
                ParticleTable.Remove(emitter);
        }

19 View Source File : ParticleManager.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public bool DestroyParticleEmitter(int emitterID)
        {
            if (emitterID == 0)
                return false;

            return ParticleTable.Remove(emitterID);
        }

19 View Source File : ParticleManager.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public int CreateParticleEmitter(PhysicsObj obj, uint emitterInfoID, int partIdx, AFrame offset, int emitterID)
        {
            if (emitterID != 0)
                ParticleTable.Remove(emitterID);

            var emitter = ParticleEmitter.makeParticleEmitter(obj);

            if (!emitter.SetInfo(emitterInfoID) || !emitter.SetParenting(partIdx, offset))
                return 0;

            emitter.InitEnd();

            var currentID = emitterID;
            if (emitterID == 0)
                currentID = NextEmitterId++;

            emitter.ID = currentID;
            ParticleTable.Add(currentID, emitter);
            return currentID;
        }

19 View Source File : ParticleManager.cs
License : GNU General Public License v3.0
Project Creator : ACEmulator

public int CreateParticleEmitter(PhysicsObj obj, uint emitterInfoID, int partIdx, AFrame offset, int emitterID)
        {
            if (emitterID != 0)
                ParticleTable.Remove(emitterID);

            var emitter = ParticleEmitter.makeParticleEmitter(obj);

            if (!emitter.SetInfo(emitterInfoID) || !emitter.SetParenting(partIdx, offset))
                return 0;

            emitter.InitEnd();

            var currentID = emitterID;
            if (emitterID == 0)
                currentID = NextEmitterId++;

            emitter.ID = currentID;
            ParticleTable[currentID] = emitter;
            return currentID;
        }

19 View Source File : CoverFlow.cs
License : GNU General Public License v3.0
Project Creator : aduskin

private void Remove(int pos)
        {
            if (!_itemShowList.TryGetValue(pos, out var item)) return;
            _visualParent.Children.Remove(item);
            _itemShowList.Remove(pos);
        }

19 View Source File : UICamera.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public static void RemoveTouch(int id)
    {
        UICamera.mTouches.Remove(id);
    }

19 View Source File : DataUpdateHandler.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public static void UnRegisterUpdateHandler(int enreplacedyId, IDataUpdateTrigger handler)
        {
            lock (Triggers)
            {
                if (Triggers == null || !Triggers.ContainsKey(enreplacedyId))
                    return;
                Triggers[enreplacedyId].Remove(handler);
                if (Triggers[enreplacedyId].Count == 0)
                    Triggers.Remove(enreplacedyId);
                if (Triggers.Count == 0)
                    Triggers = null;
            }
        }

19 View Source File : History.cs
License : GNU General Public License v3.0
Project Creator : agolaszewski

public static void Pop()
        {
            if (_current > 0)
            {
                Scopes.Remove(_current);
                _current -= 1;
            }
        }

19 View Source File : Simulator.cs
License : MIT License
Project Creator : aillieo

public bool RemoveAgent(int id)
        {
            int index = GetIndex(id);
            if (index >= 0)
            {
                managedAgents.RemoveAt(index);
                indexById.Remove(id);
                indexDirty = true;
                return true;
            }
            return false;
        }

19 View Source File : NmeaLineToAisStreamAdapter.cs
License : GNU Affero General Public License v3.0
Project Creator : ais-dotnet

private void FreeMessageFragments(int groupId)
        {
            FragmentedMessage fragmentedMessage = this.messageFragments[groupId];
            Span<byte[]> fragmentBuffers = fragmentedMessage.Buffers;
            for (int i = 0; i < fragmentBuffers.Length; ++i)
            {
                if (fragmentBuffers[i] != null)
                {
                    ArrayPool<byte>.Shared.Return(fragmentBuffers[i]);
                }
            }

            ArrayPool<byte[]>.Shared.Return(fragmentedMessage.RentedBufferArray);

            this.messageFragments.Remove(groupId);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : Alan-FGR

private static void Tests1()
    {
        int keysCount = 1 << 15;
        int maxValue = 1 << 16;
        uint umaxValue = 1 << 16;

        int[] keys = new int[keysCount];
        uint[] ukeys = new uint[keysCount];

        var r = new Random(42);
        for (int i = 0; i < keysCount; i++)
        {
            keys[i] = r.Next(maxValue);
            ukeys[i] = (uint) keys[i];
        }

        foreach (var warmup in new[] {true, false})
            for (int li = 0; li < 40; li++)
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();


                var dict = new Dictionary<int, int>();

                Measure($"Add to Dictionary", warmup, () =>
                {
                    for (int i = 0; i < keysCount; i++)
                        dict[keys[i]] = maxValue - keys[i];
                    return 0;
                });

                Measure($"Sum in Dictionary", warmup, () =>
                {
                    int checksum = 0;
                    for (int i = 0; i < keysCount; i++)
                        checksum += dict[keys[i]];
                    return checksum;
                });

                Measure($"Rem from Dictionary", warmup, () =>
                {
                    for (int i = 0; i < keysCount; i++)
                        dict.Remove(keys[i]);
                    return 0;
                });


                var sa = new SparseArray(16, 10);

                Measure($"Add to SparseArray", warmup, () =>
                {
                    for (int i = 0; i < keysCount; i++)
                        sa.Add(keys[i], maxValue - keys[i]);
                    return 0;
                });

                Measure($"Sum in SparseArray", warmup, () =>
                {
                    int checksum = 0;
                    for (int i = 0; i < keysCount; i++)
                        checksum += sa.Get(keys[i]);
                    return checksum;
                });

                //Measure($"Rem from SparseArray", warmup, () =>
                //{
                //    for (int i = 0; i < keysCount; i++)
                //        dict.Remove(keys[i]);
                //    return 0;
                //});


                var um = new UInt32UInt32Map();

                Measure($"Add to UInt32UInt32Map", warmup, () =>
                {
                    for (int i = 0; i < keysCount; i++)
                        um.GetRef(ukeys[i]) = (umaxValue - ukeys[i]);
                    return 0;
                });

                Measure($"Sum in UInt32UInt32Map", warmup, () =>
                {
                    uint checksum = 0;
                    for (int i = 0; i < keysCount; i++)
                        checksum += um.GetRef(ukeys[i]);
                    return checksum;
                });


                var im = new Int32Int32Map();

                Measure($"Add to Int32Int32Map", warmup, () =>
                {
                    for (int i = 0; i < keysCount; i++)
                        im.GetRef(keys[i]) = (maxValue - keys[i]);
                    return 0;
                });

                Measure($"Sum in Int32Int32Map", warmup, () =>
                {
                    int checksum = 0;
                    for (int i = 0; i < keysCount; i++)
                        checksum += im.GetRef(keys[i]);
                    return checksum;
                });


                /*
                var pool = new BufferPool(256).SpecializeFor<int>();
                QuickDictionary<int, int, Buffer<int>, Buffer<int>, Buffer<int>, PrimitiveComparer<int>>
                    .Create(pool, pool, pool, 2, 3, out var bdict);

                Measure($"Add to BepuDictionary", warmup, () =>
                {
                    for (int i = 0; i < keysCount; i++)
                        bdict.Add(keys[i], maxValue - keys[i], pool, pool, pool);
                    return 0;
                });

                Measure($"Sum in BepuDictionary", warmup, () =>
                {
                    int checksum = 0;
                    for (int i = 0; i < keysCount; i++)
                    {
                        bdict.TryGetValue(keys[i], out int value);
                        checksum +=  value;
                    }

                    return checksum;
                });

                Measure($"Rem from BepuDictionary", warmup, () =>
                {
                    for (int i = 0; i < keysCount; i++)
                        bdict.FastRemove(keys[i]);
                    return 0;
                });

                //dictionary.EnsureCapacity(dictionary.Count * 3, pool, pool, pool);
                //dictionary.Compact(pool, pool, pool);
                
                bdict.Dispose(pool, pool, pool);
                pool.Raw.Clear();
                */
            }


        foreach (var result in results_)
        {
            Console.WriteLine(
                $"Benchmarked avg of {result.Value.Count} samples totalling {result.Value.Average():F3} µs to {result.Key}");
        }


        //TestSetResizing<Buffer<int>, BufferPool<int>>(bufferPool);


        //var arrayPool = new ArrayPool<int>();
        //TestSetResizing<Array<int>, ArrayPool<int>>(arrayPool);
        //arrayPool.Clear();
    }

19 View Source File : BaseGraph.cs
License : MIT License
Project Creator : alelievr

public bool		RemoveNode(BaseNode removeNode, bool raiseEvents = true)
		{
			//can't delete an input/output node
			if (removeNode == inputNode || removeNode == outputNode)
				return false;
			
			if (OnNodePreRemoved != null)
				OnNodePreRemoved(removeNode);
			
			int id = removeNode.id;
			nodes.Remove(removeNode);
			
			bool success = nodesDictionary.Remove(id);

			removeNode.RemoveSelf();

			if (OnNodeRemoved != null && raiseEvents)
				OnNodeRemoved(removeNode);

			return success;
		}

19 View Source File : Runnable.cs
License : MIT License
Project Creator : alen-smajic

public bool MoveNext()
            {
                m_bMoveNext = m_Enumerator.MoveNext();
                if (m_bMoveNext && Stop)
                    m_bMoveNext = false;

                if (!m_bMoveNext)
                {
                    Runnable.Instance.m_Routines.Remove(ID);      // remove from the mapping
#if ENABLE_RUNNABLE_DEBUGGING
                    Debug.Log( string.Format("Coroutine {0} stopped.", ID ) );
#endif
                }

                return m_bMoveNext;
            }

19 View Source File : CommentaryNode.cs
License : MIT License
Project Creator : alexismorin

public void RemoveNode( ParentNode node )
		{
			if ( m_nodesOnCommentaryDict.ContainsKey( node.UniqueId ) )
			{
				UIUtils.MarkUndoAction();
				RecordObject( Constants.UndoRemoveNodeFromCommentaryId );
				node.RecordObject( Constants.UndoRemoveNodeFromCommentaryId );
				m_nodesOnCommentary.Remove( node );
				m_nodesOnCommentaryDict.Remove( node.UniqueId );
				node.OnNodeStoppedMovingEvent -= NodeStoppedMoving;
				node.OnNodeDestroyedEvent -= NodeDestroyed;
				node.CommentaryParent = -1;
			}
		}

19 View Source File : PieceManager.cs
License : MIT License
Project Creator : aljazsim

private void Piece_Completed(object sender, PieceCompletedEventArgs e)
        {
            lock (this.locker)
            {
                // only pieces not yet downloaded can be checked in
                if (this.BitField[e.PieceIndex] == PieceStatus.Missing ||
                    this.BitField[e.PieceIndex] == PieceStatus.CheckedOut)
                {
                    this.BitField[e.PieceIndex] = PieceStatus.Present;

                    this.presentPiecesCount++;
                    this.CompletedPercentage = (decimal)this.presentPiecesCount / (decimal)this.piecesCount;

                    if (this.checkouts.ContainsKey(e.PieceIndex))
                    {
                        this.checkouts.Remove(e.PieceIndex);
                    }

                    this.OnPieceCompleted(this, new PieceCompletedEventArgs(e.PieceIndex, e.PieceData));
                }
            }
        }

19 View Source File : PieceManager.cs
License : MIT License
Project Creator : aljazsim

private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            DateTime checkoutTime;
            int pieceIndex;
            HashSet<int> checkoutsToRemove = new HashSet<int>();

            Thread.CurrentThread.Name = "piece manager checker";

            this.timer.Interval = TimeSpan.FromDays(1).TotalMilliseconds;

            lock (this.locker)
            {
                foreach (var checkOut in this.checkouts)
                {
                    pieceIndex = checkOut.Key;
                    checkoutTime = checkOut.Value;

                    if (DateTime.UtcNow - checkoutTime > this.checkoutTimeout)
                    {
                        checkoutsToRemove.Add(checkOut.Key);
                    }
                }

                foreach (var checkoutToRemove in checkoutsToRemove)
                {
                    this.checkouts.Remove(checkoutToRemove);

                    // checkout timeout -> mark piece as missing, giving other peers a chance to download it
                    this.BitField[checkoutToRemove] = PieceStatus.Missing;
                }
            }

            this.timer.Interval = this.timerTimeout.TotalMilliseconds;
        }

19 View Source File : SolanaStreamingRpcClient.cs
License : MIT License
Project Creator : allartprotocol

private void RemoveSubscription(int id, bool value)
        {
            SubscriptionState sub;

            if (!confirmedSubscriptions.Remove(id))
            {
                // houston, we might have a problem?
            }

            if (value)
            {
                //sub?.ChangeState(SubscriptionStatus.Unsubscribed);
            }
            else
            {
                //sub?.ChangeState(sub.State, "Subscription doesnt exists");
            }
        }

19 View Source File : SolanaStreamingRpcClient.cs
License : MIT License
Project Creator : allartprotocol

private void ConfirmSubscription(int internalId, int resultId)
        {
            SubscriptionState sub;
            sub = unconfirmedRequests[internalId];
            if (unconfirmedRequests.Remove(internalId))
            {
                sub.SubscriptionId = resultId;
                confirmedSubscriptions.Add(resultId, sub);
            }

            sub?.ChangeState(SubscriptionStatus.Subscribed);
        }

19 View Source File : TMP_MaterialManager.cs
License : MIT License
Project Creator : Alword

public static void CleanupFallbackMaterials()
        {
            // Return if the list is empty.
            if (m_fallbackCleanupList.Count == 0) return;

            for (int i = 0; i < m_fallbackCleanupList.Count; i++)
            {
                FallbackMaterial fallback = m_fallbackCleanupList[i];

                if (fallback.count < 1)
                {
                    //Debug.Log("Cleaning up " + fallback.fallbackMaterial.name);

                    Material mat = fallback.fallbackMaterial;
                    m_fallbackMaterials.Remove(fallback.fallbackID);
                    m_fallbackMaterialLookup.Remove(mat.GetInstanceID());
                    Object.DestroyImmediate(mat);
                    mat = null;
                }
            }

            m_fallbackCleanupList.Clear();
        }

19 View Source File : TMP_StyleSheet.cs
License : MIT License
Project Creator : Alword

public void UpdateStyleDictionaryKey(int old_key, int new_key)
        {
            if (m_StyleDictionary.ContainsKey(old_key))
            {
                TMP_Style style = m_StyleDictionary[old_key];
                m_StyleDictionary.Add(new_key, style);
                m_StyleDictionary.Remove(old_key);
            }
        }

19 View Source File : TMP_UpdateRegistery.cs
License : MIT License
Project Creator : Alword

private void InternalUnRegisterCanvasElementForLayoutRebuild(ICanvasElement element)
        {
            int id = (element as Object).GetInstanceID();

            //element.LayoutComplete();
            TMP_UpdateRegistry.instance.m_LayoutRebuildQueue.Remove(element);
            m_GraphicQueueLookup.Remove(id);
        }

19 View Source File : TMP_UpdateRegistery.cs
License : MIT License
Project Creator : Alword

private void InternalUnRegisterCanvasElementForGraphicRebuild(ICanvasElement element)
        {
            int id = (element as Object).GetInstanceID();

            //element.GraphicUpdateComplete();
            TMP_UpdateRegistry.instance.m_GraphicRebuildQueue.Remove(element);
            m_LayoutQueueLookup.Remove(id);
        }

19 View Source File : Path.cs
License : MIT License
Project Creator : AmigoCap

protected void CleanspecialRadii() {
            int AtomCount = atoms.Count;
            List<int> keysToRemove = new List<int>();
            foreach (KeyValuePair<int, float> pair in specialRadii) {
                if (pair.Key > AtomCount - 2 || pair.Key < 0)
                    keysToRemove.Add(pair.Key);
            }
            foreach (int key in keysToRemove)
                specialRadii.Remove(key);
        }

19 View Source File : GlobalCommandHook.cs
License : Apache License 2.0
Project Creator : AmpScm

public void UnhookCommand(System.ComponentModel.Design.CommandID command, EventHandler handler)
        {
            if (command == null)
                throw new ArgumentNullException("command");
            else if (handler == null)
                throw new ArgumentNullException("handler");
            Dictionary<int, EventHandler> map;

            if (!_commandMap.TryGetValue(command.Guid, out map))
                return;

            EventHandler handlers;
            if (!map.TryGetValue(command.ID, out handlers))
                return;

            handlers -= handler;

            if (handlers == null)
            {
                map.Remove(command.ID);

                if (map.Count == 0)
                {
                    _commandMap.Remove(command.Guid);

                    if (_commandMap.Count == 0)
                    {
                        Unhook();
                    }
                }
            }

            map[command.ID] = (handlers + handler);
        }

19 View Source File : BuilderPlug.cs
License : GNU General Public License v3.0
Project Creator : anotak

public void CleanUpRejectStates()
		{
			UpdateFixedIndexLookupTable();

			List<int> sourcesectors = new List<int>(changes.Keys);
			foreach(int ss in sourcesectors)
			{
				List<RejectSet> states = changes[ss];

				// Remove any items for which the target sector can't be found
				for(int i = states.Count - 1; i >= 0; i--)
				{
					if(GetSectorByFixedIndex(states[i].target) == null)
						states.RemoveAt(i);
				}

				// If no states remaining, remove the source sector and list from lookup table
				if(states.Count == 0)
					changes.Remove(ss);
			}
		}

19 View Source File : RecastPathComponent.cs
License : MIT License
Project Creator : AnotherEnd15

public void UnLoadMapNavData(int mapId)
        {
            if (!m_RecastPathProcessorDic.ContainsKey(mapId))
            {
                Log.Warning($"不存在Id为{mapId}的地图Nav数据,无法进行卸载!");
                return;
            }

            m_RecastPathProcessorDic[mapId].Dispose();
            m_RecastPathProcessorDic.Remove(mapId);
            if (RecastInterface.FreeMap(mapId))
            {
                Log.Info($"地图: {mapId}  释放成功");
            }
            else
            {
                Log.Info($"地图: {mapId}  释放失败");
            }
        }

19 View Source File : Session.cs
License : MIT License
Project Creator : AnotherEnd15

public void OnRead(ushort opcode, IResponse response)
        {
            OpcodeHelper.LogMsg(this.DomainZone(), opcode, response);
            
            if (!this.requestCallbacks.TryGetValue(response.RpcId, out var action))
            {
                return;
            }

            this.requestCallbacks.Remove(response.RpcId);
            if (ErrorCode.IsRpcNeedThrowException(response.Error))
            {
                action.Tcs.SetException(new Exception($"Rpc error, request: {action.Request} response: {response}"));
                return;
            }
            action.Tcs.SetResult(response);
        }

19 View Source File : Session.cs
License : MIT License
Project Creator : AnotherEnd15

public async ETTask<IResponse> Call(IRequest request, ETCancellationToken cancellationToken)
        {
            int rpcId = ++RpcId;
            RpcInfo rpcInfo = new RpcInfo(request);
            this.requestCallbacks[rpcId] = rpcInfo;
            request.RpcId = rpcId;

            this.Send(request);
            
            void CancelAction()
            {
                if (!this.requestCallbacks.TryGetValue(rpcId, out RpcInfo action))
                {
                    return;
                }

                this.requestCallbacks.Remove(rpcId);
                Type responseType = OpcodeTypeComponent.Instance.GetResponseType(action.Request.GetType());
                IResponse response = (IResponse) Activator.CreateInstance(responseType);
                response.Error = ErrorCode.ERR_Cancel;
                action.Tcs.SetResult(response);
            }

            IResponse ret;
            try
            {
                cancellationToken?.Add(CancelAction);
                ret = await rpcInfo.Tcs.Task;
            }
            finally
            {
                cancellationToken?.Remove(CancelAction);
            }
            return ret;
        }

19 View Source File : GameMainManager.cs
License : Apache License 2.0
Project Creator : AnotherEnd15

void DeleteAgent()
    {

        int agentNo = Simulator.Instance.queryNearAgent(mousePosition, 1.5f);
        if (agentNo == -1 || !magentMap.ContainsKey(agentNo))
            return;

        Simulator.Instance.delAgent(agentNo);
        LeanPool.Despawn(magentMap[agentNo].gameObject);
        magentMap.Remove(agentNo);
    }

19 View Source File : ApexComponentMaster.cs
License : GNU Lesser General Public License v3.0
Project Creator : ApexGameTools

public void Cleanup()
        {
            ComponentInfo toRemove = null;
            foreach (var c in _components.Values)
            {
                if (c.component.Equals(null))
                {
                    toRemove = c;
                }
            }

            if (toRemove != null)
            {
                RemoveHidden(toRemove);
                _components.Remove(toRemove.id);
                toRemove.category.Remove(toRemove);

                if (toRemove.category.count == 0)
                {
                    _categories.Remove(toRemove.category.name);
                }
            }
        }

19 View Source File : IMGUI.cs
License : MIT License
Project Creator : Apostolique

private void Remove(int id, IComponent c) {
            if (Focus == id) {
                Focus = null;
            }

            _activeComponents.Remove(id);
            c.Parent?.Remove(c);
            // TODO: Remove from PendingComponents? Probably not since that case can't happen?
        }

19 View Source File : ExcelWorksheet.cs
License : Apache License 2.0
Project Creator : Appdynamics

internal void AdjustFormulasRow(int rowFrom, int rows)
        {
            var delSF = new List<int>();
            foreach (var sf in _sharedFormulas.Values)
            {
                var a = new ExcelAddress(sf.Address).DeleteRow(rowFrom, rows);
                if (a==null)
                {
                    delSF.Add(sf.Index);
                }
                else
                {
                    sf.Address = a.Address;
                    if (sf.StartRow > rowFrom)
                    {
                        var r = Math.Min(sf.StartRow - rowFrom, rows);
                        sf.Formula = ExcelCellBase.UpdateFormulaReferences(sf.Formula, -r, 0, rowFrom, 0, this.Name, this.Name);
                        sf.StartRow -= r;
                    }
                }
            }
            foreach (var ix in delSF)
            {
                _sharedFormulas.Remove(ix);
            }
            delSF = null;
            var cse = new CellsStoreEnumerator<object>(_formulas, 1, 1, ExcelPackage.MaxRows, ExcelPackage.MaxColumns);
            while (cse.Next())
            {
                if (cse.Value is string)
                {
                    cse.Value = ExcelCellBase.UpdateFormulaReferences(cse.Value.ToString(), -rows, 0, rowFrom, 0, this.Name, this.Name);
                }
            }
        }

19 View Source File : ExcelWorksheet.cs
License : Apache License 2.0
Project Creator : Appdynamics

internal void AdjustFormulasColumn(int columnFrom, int columns)
        {
            var delSF = new List<int>();
            foreach (var sf in _sharedFormulas.Values)
            {
                var a = new ExcelAddress(sf.Address).DeleteColumn(columnFrom, columns);
                if (a == null)
                {
                    delSF.Add(sf.Index);
                }
                else
                {
                    sf.Address = a.Address;
                    //sf.Formula = ExcelCellBase.UpdateFormulaReferences(sf.Formula, 0, -columns, 0, columnFrom);
                    if (sf.StartCol > columnFrom)
                    {
                        var c = Math.Min(sf.StartCol - columnFrom, columns);
                        sf.Formula = ExcelCellBase.UpdateFormulaReferences(sf.Formula, 0, -c, 0, 1, this.Name, this.Name);
                        sf.StartCol-= c;
                    }

                    //sf.Address = a.Address;
                    //sf.Formula = ExcelCellBase.UpdateFormulaReferences(sf.Formula, 0,-columns,0, columnFrom);
                    //if (sf.StartCol >= columnFrom)
                    //{
                    //    sf.StartCol -= sf.StartCol;
                    //}
                }
            }
            foreach (var ix in delSF)
            {
                _sharedFormulas.Remove(ix);
            }
            delSF = null;
            var cse = new CellsStoreEnumerator<object>(_formulas, 1, 1,  ExcelPackage.MaxRows, ExcelPackage.MaxColumns);
            while (cse.Next())
            {
                if (cse.Value is string)
                {
                    cse.Value = ExcelCellBase.UpdateFormulaReferences(cse.Value.ToString(), 0, -columns, 0, columnFrom, this.Name, this.Name);
                }
            }
        }

19 View Source File : ExcelWorksheet.cs
License : Apache License 2.0
Project Creator : Appdynamics

private void FixSharedFormulas()
        {
            var remove = new List<int>();
            foreach (var f in _sharedFormulas.Values)
            {
                var addr = new ExcelAddressBase(f.Address);
                var shIx = _formulas.GetValue(addr._fromRow, addr._fromCol);
                if (!(shIx is int) || (shIx is int && (int)shIx != f.Index))
                {
                    for (var row = addr._fromRow; row <= addr._toRow; row++)
                    {
                        for (var col = addr._fromCol; col <= addr._toCol; col++)
                        {
                            if (!(addr._fromRow == row && addr._fromCol == col))
                            {
                                var fIx=_formulas.GetValue(row, col);
                                if (fIx is int && (int)fIx == f.Index)
                                {
                                    _formulas.SetValue(row, col, f.GetFormula(row, col, this.Name));
                                }
                            }
                        }
                    }
                    remove.Add(f.Index);
                }
            }
            remove.ForEach(i => _sharedFormulas.Remove(i));
        }

See More Examples