/// <summary> /// Buffers an Add/Remove/Clear operation so that it can be executed on the collection when enumeration is complete. /// </summary> /// <param name="opType">The operation type.</param> /// <param name="item">The item to act on. This parameter is ignored if the operation type is Clear.</param> private void BufferOperation(NListBufferedOperationType opType, T item) { _buffer[_numItemsInBuffer] = new NListBufferedOperation <T>(opType, item); _numItemsInBuffer++; //grow array if the buffer index is larger than the array size, no choice but to allocate from heap. if (_numItemsInBuffer >= _buffer.Length) { #if TRACE && WINDOWS Trace.WriteLine(typeof(T).ToString() + ":\t\tResizing NList for type: " + typeof(T) + ". New size: " + (_buffer.Length + ResizeAmount)); #endif var tempBuffer = new NListBufferedOperation <T> [_buffer.Length + ResizeAmount]; Array.Copy(_buffer, tempBuffer, _buffer.Length); _buffer = tempBuffer; } }
public NListBufferedOperation(NListBufferedOperationType opType, T item) { OperationType = opType; Item = item; }