コード例 #1
0
            public bool Add(THashKey hashKey, TElement element, TOrderKey orderKey)
            {
                bool hasCollision = true;

                ListChunk <TElement>?currentValue = default(ListChunk <TElement>);

                if (!_base.TryGetValue(hashKey, ref currentValue))
                {
                    const int INITIAL_CHUNK_SIZE = 2;
                    currentValue = new ListChunk <TElement>(INITIAL_CHUNK_SIZE);
                    _base.Add(hashKey, currentValue);
                    hasCollision = false;
                }

                currentValue.Add(element);

                return(hasCollision);
            }
コード例 #2
0
            public bool Add(THashKey hashKey, TElement element, TOrderKey orderKey)
            {
                HashLookupValueList <TElement, TOrderKey> currentValue = default(HashLookupValueList <TElement, TOrderKey>);

                if (!_base.TryGetValue(hashKey, ref currentValue))
                {
                    currentValue = new HashLookupValueList <TElement, TOrderKey>(element, orderKey);
                    _base.Add(hashKey, currentValue);
                    return(false);
                }
                else
                {
                    if (currentValue.Add(element, orderKey))
                    {
                        // We need to re-store this element because the pair is a value type.
                        _base[hashKey] = currentValue;
                    }
                    return(true);
                }
            }
コード例 #3
0
            public bool Add(THashKey hashKey, TElement element, TOrderKey orderKey)
            {
                bool hasCollision = true;

                GroupKeyData?currentValue = default(GroupKeyData);

                if (!_base.TryGetValue(hashKey, ref currentValue))
                {
                    currentValue = new GroupKeyData(orderKey, hashKey, _orderKeyComparer);
                    _base.Add(hashKey, currentValue);
                    hasCollision = false;
                }

                currentValue._grouping.Add(element, orderKey);
                if (_orderKeyComparer.Compare(orderKey, currentValue._orderKey) < 0)
                {
                    currentValue._orderKey = orderKey;
                }

                return(hasCollision);
            }
コード例 #4
0
 internal GroupKeyData(TOrderKey orderKey, THashKey hashKey, IComparer <TOrderKey> orderComparer)
 {
     _orderKey = orderKey;
     _grouping = new OrderedGroupByGrouping <THashKey, TOrderKey, TElement>(hashKey, orderComparer);
 }