示例#1
0
        public void AddBefore(IBaseNode <T> node, T data)
        {
            IBaseNode <T> newNode = new Node <T>(data);

            if (Count != 0)
            {
                IBaseNode <T> prev    = null;
                IBaseNode <T> current = Head;

                while (current != null)
                {
                    if (current.Equals(node))
                    {
                        if (prev == null)
                        {
                            newNode.Next = Head;
                            Head         = newNode;
                            IncrementIndex();
                        }
                        else
                        {
                            prev.Next    = newNode;
                            newNode.Next = current;
                            DecrementIndex();
                        }
                    }
                    prev    = current;
                    current = current.Next;
                }
            }
        }
示例#2
0
        protected bool TreeNodeContains(TreeNode treeNode, IBaseNode obj)
        {
            IBaseNode tag = treeNode.Tag as IBaseNode;

            if (tag != null && tag.Equals(obj))
            {
                return(true);
            }

            foreach (TreeNode node in treeNode.Nodes)
            {
                if (TreeNodeContains(node, obj))
                {
                    return(true);
                }
            }

            return(false);
        }