Patterns/NodeT.cs

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;


namespace ComLib.Patterns
{
    /// <summary>
    /// Interface designating a node with id, parent id and name.
    /// </summary>
    public interface INodeWithIds
    {
        /// <summary>
        /// Id of the node.
        /// </summary>
        int Id { get; }


        /// <summary>
        /// Name of the node.
        /// </summary>
        string Name { get; }


        /// <summary>
        /// Id of the parent of this node.
        /// </summary>
        int ParentId { get; }
    }


    /// <summary>
    /// Node to represent a root node.
    /// </summary>
    /// <typeparam name="T">Type of elements.</typeparam>
    public class NodeRoot<T> : Node<T>
    {   
        IDictionary<int, Node<T>> _nodesById = new Dictionary<int, Node<T>>();
        IDictionary<string, Node<T>> _nodesByName = new Dictionary<string, Node<T>>();


        /// <summary>
        /// Default initialization.
        /// </summary>
        public NodeRoot()
        {
            _parent = this;
            _root = this;
        }
    

        /// <summary>
        /// Get node by it's id.
        /// </summary>
        /// <param name="id">Node id.</param>
        /// <returns>Node designated by id.</returns>
        public Node<T> this[ int id]
        {
后面还有 240 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。