public void AddFirst(DataBlock block) { if (_firstBlock == null) AddBlockToEmptyMap(block); else AddBeforeInternal(_firstBlock, block); }
void InvalidateBlock(DataBlock block) { block._map = null; block._nextBlock = null; block._previousBlock = null; }
public void Clear() { DataBlock block = FirstBlock; while (block != null) { DataBlock nextBlock = block.NextBlock; InvalidateBlock(block); block = nextBlock; } _firstBlock = null; _count = 0; _version++; }
public void AddLast(DataBlock block) { if (_firstBlock == null) AddBlockToEmptyMap(block); else AddAfterInternal(GetLastBlock(), block); }
public DataBlock Replace(DataBlock block, DataBlock newBlock) { AddAfterInternal(block, newBlock); RemoveInternal(block); return newBlock; }
public void AddBefore(DataBlock block, DataBlock newBlock) { AddBeforeInternal(block, newBlock); }
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; }
public void Remove(DataBlock block) { RemoveInternal(block); }
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++; }
internal Enumerator(DataMap map) { _map = map; _version = map._version; _current = null; _index = -1; }
void AddBlockToEmptyMap(DataBlock block) { block._map = this; block._nextBlock = null; block._previousBlock = null; _firstBlock = block; _version++; _count++; }
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++; }
public void AddAfter(DataBlock block, DataBlock newBlock) { AddAfterInternal(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); }
public DataBlock Replace(DataBlock block, DataBlock newBlock) { AddAfterInternal(block, newBlock); RemoveInternal(block); return(newBlock); }