public void AddFirst(DataBlock block) { if (_firstBlock == null) { AddBlockToEmptyMap(block); } else { AddBeforeInternal(_firstBlock, block); } }
public void AddLast(DataBlock block) { if (_firstBlock == null) { AddBlockToEmptyMap(block); } else { AddAfterInternal(GetLastBlock(), block); } }
FileDataBlock GetNextFileDataBlock(DataBlock block, long dataOffset, out long nextDataOffset) { // Iterate over the remaining blocks until a file block is encountered. nextDataOffset = dataOffset + block.Length; block = block.NextBlock; while (block != null) { FileDataBlock fileBlock = block as FileDataBlock; if (fileBlock != null) { return fileBlock; } nextDataOffset += block.Length; block = block.NextBlock; } return null; }
public DataBlock Replace(DataBlock block, DataBlock newBlock) { AddAfterInternal(block, newBlock); RemoveInternal(block); return newBlock; }
public void Remove(DataBlock block) { RemoveInternal(block); }
public void AddAfter(DataBlock block, DataBlock newBlock) { AddAfterInternal(block, newBlock); }
public void AddBefore(DataBlock block, DataBlock newBlock) { AddBeforeInternal(block, newBlock); }
public bool MoveNext() { if (this._version != _map._version) { throw new InvalidOperationException("Collection was modified after the enumerator was instantiated."); } if (_index >= _map.Count) { return false; } if (++_index == 0) { _current = _map.FirstBlock; } else { _current = _current.NextBlock; } return (_index < _map.Count); }
void IEnumerator.Reset() { if (this._version != this._map._version) { throw new InvalidOperationException("Collection was modified after the enumerator was instantiated."); } this._index = -1; this._current = null; }
void AddBlockToEmptyMap(DataBlock block) { block._map = this; block._nextBlock = null; block._previousBlock = null; _firstBlock = block; _version++; _count++; }
internal Enumerator(DataMap map) { _map = map; _version = map._version; _current = null; _index = -1; }
void InvalidateBlock(DataBlock block) { block._map = null; block._nextBlock = null; block._previousBlock = null; }
void RemoveInternal(DataBlock block) { DataBlock previousBlock = block._previousBlock; DataBlock nextBlock = block._nextBlock; if (previousBlock != null) { previousBlock._nextBlock = nextBlock; } if (nextBlock != null) { nextBlock._previousBlock = previousBlock; } if (_firstBlock == block) { _firstBlock = nextBlock; } InvalidateBlock(block); _count--; _version++; }
void AddBeforeInternal(DataBlock block, DataBlock newBlock) { newBlock._nextBlock = block; newBlock._previousBlock = block._previousBlock; newBlock._map = this; if (block._previousBlock != null) { block._previousBlock._nextBlock = newBlock; } block._previousBlock = newBlock; if (_firstBlock == block) { _firstBlock = newBlock; } this._version++; this._count++; }
void AddAfterInternal(DataBlock block, DataBlock newBlock) { newBlock._previousBlock = block; newBlock._nextBlock = block._nextBlock; newBlock._map = this; if (block._nextBlock != null) { block._nextBlock._previousBlock = newBlock; } block._nextBlock = newBlock; this._version++; this._count++; }
public void Clear() { DataBlock block = FirstBlock; while (block != null) { DataBlock nextBlock = block.NextBlock; InvalidateBlock(block); block = nextBlock; } _firstBlock = null; _count = 0; _version++; }