Contains() public méthode

Checks to see if the key exists in the dictionary.
public Contains ( object key ) : bool
key object
Résultat bool
        public override bool Contains(object key)
        {
            if (_hidden.Contains(key))
            {
                return(false);
            }

            return(_data.ContainsKey(key));
        }
Exemple #2
0
        public override bool Contains(object key)
        {
            if (_hidden.Contains(key))
            {
                return(false);
            }

            string strKey = key as string;

            if (strKey != null)
            {
                return(_data.ContainsKey(SymbolTable.StringToId(strKey)));
            }
            else
            {
                return(_data.ContainsObjectKey(key));
            }
        }
Exemple #3
0
        public override bool Contains(object key)
        {
            if (key is string && TryGetExtraValue((string)key, out object dummy))
            {
                return(dummy != Uninitialized.Instance);
            }

            return(_storage.Contains(key));
        }
Exemple #4
0
        public bool __contains__(object value)
        {
            // promote sets to FrozenSets for contains checks (so we get a hash code)
            value = SetHelpers.GetHashableSetIfSet(value);

            if (_items.Count == 0)
            {
                PythonOps.Hash(DefaultContext.Default, value);    // make sure we have a hashable item
            }
            return(_items.Contains(value));
        }
Exemple #5
0
        public override bool Remove(ref DictionaryStorage storage, object key)
        {
            if (_storage.Contains(key))
            {
                lock (this) {
                    if (storage == this)
                    {
                        var newStore = new CommonDictionaryStorage();
                        _storage.CopyTo(newStore);
                        newStore.Remove(key);
                        storage = newStore;
                        return(true);
                    }
                }

                // race, try again
                return(storage.Remove(ref storage, key));
            }

            return(false);
        }
Exemple #6
0
 public override bool Contains(object key)
 {
     return(_storage.Contains(key));
 }