public LookupCollection(SerializableLookup <TKey, TElement> lookup, TKey key)
            {
                var indexes = new List <int>();

                foreach (var i in lookup.FindEntries(key))
                {
                    indexes.Add(i);
                }
                indexes.Reverse();

                this.version = lookup.version;
                this.indexes = indexes;
                this.lookup  = lookup;
            }
        public void TrimExcess()
        {
            var newLookup = new SerializableLookup <TKey, TElement>(Count, true);

            foreach (var g in this)
            {
                foreach (var item in g)
                {
                    newLookup.Add(g.Key, item);
                }
            }

            // copy internal field to this
            this.buckets         = newLookup.buckets;
            this.count           = newLookup.count;
            this.entriesHashCode = newLookup.entriesHashCode;
            this.entriesKey      = newLookup.entriesKey;
            this.entriesNext     = newLookup.entriesNext;
            this.entriesValue    = newLookup.entriesValue;
        }
 public Grouping(SerializableLookup <TKey, TElement> lookup, TKey key)
 {
     this.lookup = lookup;
     this.Key    = key;
 }