/// <summary> /// Initializes a new instance of <see cref="LockFreeArrayBasedDictionary{TKey,TValue}" />. /// </summary> /// <param name="options">The options that specify the service objects used by this dictionary.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="options" /> is null.</exception> public LockFreeArrayBasedDictionary(Options options) { options.MustNotBeNull(nameof(options)); _keyComparer = options.KeyComparer; _valueComparer = options.ValueComparer; _growArrayStrategy = options.GrowArrayStrategy; _growArrayProcessFactory = options.GrowArrayProcessFactory; _backgroundCopyTaskFactory = options.BackgroundCopyTaskFactory; _currentArray = CreateInitialArray(); _setNewArray = SetNewArray; }
public ReaderWriterLockedList(IEnumerable <T> items = null, IEqualityComparer <T> equalityComparer = null, IReaderWriterLock @lock = null, IGrowArrayStrategy <T> growArrayStrategy = null) { _equalityComparer = equalityComparer ?? EqualityComparer <T> .Default; _lock = @lock ?? new ReaderWriterLockSlim(); _growArrayStrategy = growArrayStrategy ?? new DoubleArraySizeStrategy <T>(); IReadOnlyList <T> initialItems = null; if (items != null) { initialItems = items.AsReadOnlyList(); } _internalArray = _growArrayStrategy.CreateInitialArray(initialItems); _count = initialItems?.Count ?? 0; }