/// <summary> /// Reallocates already allocated value and produces reference to it. /// </summary> /// <param name="reference">Reference to the already allocated value</param> /// <param name="newValue">New value to allocate</param> /// <returns>Reference to reallocated value</returns> public DbItemReference Reallocate(DbItemReference reference, TValue newValue) { var str = reference.ToString(); _dictionary.Remove(str); return(AllocateNew(newValue)); }
/// <summary> /// Allocates a new value and produces reference to it. /// </summary> /// <param name="value">Value to allocate</param> /// <returns>Reference to allocated value</returns> public DbItemReference AllocateNew(TValue value) { var reference = new DbItemReference(_index++, 0); _dictionary.Add(reference.ToString(), value); return(reference); }
public void Remove(DbItemReference reference) { if (_rootNodeReference.Equals(reference)) { throw new ArgumentOutOfRangeException(nameof(reference), "Unable to delete the root node"); } _nodes.Remove(reference.ToString()); }
public IRadixTreeNode Fetch(DbItemReference reference) { var str = reference.ToString(); return(_nodes.ContainsKey(str) ? _nodes[str] : null); }
public IRadixTreeNode FetchRoot() { return(_nodes[_rootNodeReference.ToString()]); }
/// <summary> /// Release allocated value. /// </summary> /// <param name="reference">Reference to allocated value</param> public void Free(DbItemReference reference) { _dictionary.Remove(reference.ToString()); }
public TValue Fetch(DbItemReference reference) { return(_dictionary[reference.ToString()]); }