Пример #1
0
        public void Add(TValue value)
        {
            var key = this.keySelector(value);
            SortedGroup <TKey, TValue> group;

            if (this.keyLookup.ContainsKey(key))
            {
                group = this.keyLookup[key];
            }
            else
            {
                group = new SortedGroup <TKey, TValue>(key, this.valueComparer);
                this.keyLookup.Add(key, group);
                var index = this.BinarySearch(group, this.groupComparer);
                if (index < 0)
                {
                    index = ~index;
                }
                this.Insert(index, group);
            }

            group.Add(value);
        }
Пример #2
0
 public int Compare(SortedGroup <TKey, TValue> x, SortedGroup <TKey, TValue> y) => this.groupComparer.Compare(x.Key, y.Key);