/// <summary>
                /// Requires that scope is either the same as <see cref="_currentScope"/>,
                /// or is the <see cref="Scope.Parent"/> of <see cref="_currentScope"/>.
                /// Returns imediately in the first case,
                /// Replaces <see cref="_currentScope"/> with scope in the second.
                /// </summary>
                /// <param name="scope"></param>
                private void PopScope(Scope scope)
                {
                    if (scope == _currentScope)
                    {
                        return;
                    }

                    Debug.Assert(scope == _currentScope.Parent, $"{nameof(scope)} must be {nameof(_currentScope)} or {nameof(_currentScope)}.{nameof(_currentScope.Parent)}");

                    // Since it is forbidden to jump into a scope,
                    // we can forget all information we have about labels in the child scope

                    var labels = _labelsInScope.Pop();

                    foreach (var label in labels)
                    {
                        var scopes = _scopesAfterLabel[label];
                        scopes.Free();
                        _scopesAfterLabel.Remove(label);
                    }

                    labels.Free();

                    _currentScope = _currentScope.Parent;
                }
Esempio n. 2
0
        internal void RemoveEntity(RawEntity entity)
        {
            var idx = IndexOf(entity);

            foreach (var component in Components.Values)
            {
                component.RemoveAt(idx);
            }

            entities.RemoveAt(idx);
            // swapping back the index of the next entity to the previous index
            if (idx < entities.Count)
            {
                entityToIndex.Remove(entity);
                entityToIndex[entities[idx]] = idx;
                Parallel.For(idx, entities.Count, updateEntityIndex);
            }
        }
Esempio n. 3
0
        public static void OutOfBoundsRegression()
        {
            var dictionary = new PooledDictionary <string, string>();

            foreach (var item in TestData.GetData())
            {
                var operation = item.Item1;
                var keyBase64 = item.Item2;

                var key = keyBase64.Length > 0 ? GetString(Convert.FromBase64String(keyBase64)) : string.Empty;

                if (operation == InputAction.Add)
                {
                    dictionary[key] = key;
                }
                else if (operation == InputAction.Delete)
                {
                    dictionary.Remove(key);
                }
            }

            dictionary.Dispose();
        }
 public bool Remove(TKey key)
 {
     Debug.Assert(!IsDisposed);
     return(_coreAnalysisData.Remove(key));
 }
Esempio n. 5
0
        public void TestNoRemove2()
        {
            using var dict = new PooledDictionary <string, string>();

            Assert.Throws <NotSupportedException>(() => dict.Remove(new KeyValuePair <string, string>("", "")));
        }
 public void RemoveSource(string hintName)
 {
     _sourcesAdded.Remove(hintName);
 }