示例#1
0
        private bool RemoveItem(TSource item)
        {
            GroupAndElement info;

            if (_outputShadowMap.TryGetValue(item, out info))
            {
                _outputShadowMap.Remove(item);
                GroupedContinuousCollection <TKey, TElement> group = info.Group;
                bool wasRemoved;
                try
                {
                    group.IsSealed = false;
                    wasRemoved     = group.Remove(info.Element);
                }
                finally
                {
                    group.IsSealed = true;
                }
                if (group.Count == 0)
                {
                    this.OutputCollection.Remove(group);
                    _groupMap.Remove(group.Key);
                }
                return(wasRemoved);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        private void AddItem(TSource item, TElement element)
        {
            TKey theKey = _keySelector(item);
            GroupedContinuousCollection <TKey, TElement> outputGroup;

            if (_groupMap.TryGetValue(theKey, out outputGroup) == false)
            {
                outputGroup = new GroupedContinuousCollection <TKey, TElement>(theKey, _comparer);
                this.OutputCollection.Add(outputGroup);
                _groupMap[theKey] = outputGroup;
            }
            try
            {
                outputGroup.IsSealed = false;
                outputGroup.Add(element);
            }
            finally
            {
                outputGroup.IsSealed = true;
            }
            _outputShadowMap[item] = new GroupAndElement(outputGroup, element);
        }
 public bool Equals(GroupedContinuousCollection <TKey, TElement> other)
 {
     return(_comparer.Equals(this.Key, other.Key));
 }
示例#4
0
 public GroupAndElement(GroupedContinuousCollection <TKey, TElement> group, TElement element)
 {
     this.Group   = group;
     this.Element = element;
 }