示例#1
0
        private void addAtTop(LinkedNode nodeToAdd)
        {
            nodeToAdd.right = first;
            nodeToAdd.left  = null;

            if (first != null)
            {
                first.left = nodeToAdd;
            }

            first = nodeToAdd;

            if (last == null)
            {
                last = first;
            }
        }
示例#2
0
        private void removeNode(LinkedNode nodeToRemove)
        {
            if (nodeToRemove.left != null)
            {
                nodeToRemove.left.right = nodeToRemove.right;
            }
            else
            {
                first = nodeToRemove.right;
            }

            if (nodeToRemove.right != null)
            {
                nodeToRemove.right.left = nodeToRemove.left;
            }
            else
            {
                last = nodeToRemove.left;
            }
        }