public DictionaryInt(DictionaryInt <TValue> dictionary, IEqualityComparer <TKey> comparer) : this(dictionary != null? dictionary.Count: 0, comparer) { foreach (KeyValuePair <TKey, TValue> pair in dictionary) { Add(pair.Key, pair.Value); } }
/*public void CopyFrom(DictionaryInt<TValue> other) { * * this.Clear(); * foreach (var item in other) { * * this.Add(item.Key, item.Value); * * } * * this.version = other.version; * * } * * private struct EntryCopy<T> : IArrayElementCopy<Entry> where T : IArrayElementCopy<TValue> { * * public T copy; * * public void Copy(Entry @from, ref Entry to) { * * this.copy.Copy(from.value, ref to.value); * to.key = from.key; * to.next = from.next; * to.hashCode = from.hashCode; * * } * * public void Recycle(Entry item) { * * this.copy.Recycle(item.value); * * } * * } * * public void CopyFrom<TCopy>(DictionaryInt<TValue> other, TCopy copy) where TCopy : IArrayElementCopy<TValue> { * * this.Clear(copy); * foreach (var item in other) { * * this.Insert(item.Key, item.Value, true, copy); * * } * * this.version = other.version; * * }*/ public void CopyFrom(DictionaryInt <TValue> other) { ArrayUtils.Copy(other.buckets, ref this.buckets); ArrayUtils.Copy(other.entries, ref this.entries); this.count = other.count; this.version = other.version; this.freeList = other.freeList; this.freeCount = other.freeCount; }
public void CopyFrom <TCopy>(DictionaryInt <TValue> other, TCopy copy) where TCopy : IArrayElementCopy <TValue> { ArrayUtils.Copy(other.buckets, ref this.buckets); ArrayUtils.Copy(other.entries, ref this.entries, new EntryCopy <TCopy>() { copy = copy }); this.count = other.count; this.version = other.version; this.freeList = other.freeList; this.freeCount = other.freeCount; }
public DictionaryInt(DictionaryInt <TValue> dictionary) : this(dictionary, null) { }