Пример #1
0
        /// <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));
        }
Пример #2
0
        /// <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()]);
 }
Пример #6
0
 /// <summary>
 /// Release allocated value.
 /// </summary>
 /// <param name="reference">Reference to allocated value</param>
 public void Free(DbItemReference reference)
 {
     _dictionary.Remove(reference.ToString());
 }
Пример #7
0
 public TValue Fetch(DbItemReference reference)
 {
     return(_dictionary[reference.ToString()]);
 }