public void BatchItem(TKey key, TValue value, bool dontOptimize = false) { if (!dontOptimize) { ElementCount++; BatchGroup <TKey, TValue> group; if (TryGetGroup(key, out group)) { group.List.Add(value); } else { BatchGroup <TKey, TValue> batch = CreateBatch(key); batch.Add(value); batched.Add(batch); } } else { unoptimizedBatch.Add(value); } }