示例#1
0
        public bool TryGetValue(TKey key, out TValue value)
        {
            object oldValObj = _table.TryGetValue(key);

            Debug.Assert(!(oldValObj is Prime));

            if (oldValObj != null)
            {
                // PERF: this would be nice to have as a helper,
                // but it does not get inlined
                if (default(TValue) == null && oldValObj == NULLVALUE)
                {
                    value = default(TValue);
                }
                else
                {
                    value = (TValue)oldValObj;
                }
                return(true);
            }

            value = default(TValue);
            return(false);
        }
示例#2
0
            public bool MoveNext()
            {
                if (_nextV == NULLVALUE)
                {
                    return(false);
                }

                _curKey   = _nextK;
                _curValue = _nextV;
                _nextV    = NULLVALUE;

                var entries = _table._entries;

                while (_idx < entries.Length)
                {  // Scan array
                    var nextEntry = entries[_idx++];

                    if (nextEntry.value != null)
                    {
                        var nextK = _table.keyFromEntry(nextEntry.key);

                        object nextV = _table.TryGetValue(nextK);
                        if (nextV != null)
                        {
                            _nextK = nextK;

                            // PERF: this would be nice to have as a helper,
                            // but it does not get inlined
                            if (default(TValue) == null && nextV == NULLVALUE)
                            {
                                _nextV = default(TValue);
                            }
                            else
                            {
                                _nextV = (TValue)nextV;
                            }


                            break;
                        }
                    }
                }

                return(_curValue != NULLVALUE);
            }