Example #1
0
        /// <summary>
        /// Creates the index for the node.
        /// </summary>
        /// <returns>Returns true if the index was created successfully, or false if it not possible
        /// to create a new index for this node.</returns>
        /// <remarks>This method should be called after the node is added to a list.</remarks>
        internal bool CreateIndex()
        {
            bool success = false;

            if (this.next == null)
            {
                if (this.previous == null)
                {
                    // This is the only node in the list.
                    success = NodeIndex.CreateFirst(out this.index);
                }
                else
                {
                    // This is the last node in the list.
                    success = NodeIndex.CreateAfter(this.previous.index, out this.index);
                }
            }
            else if (this.previous == null)
            {
                // This is the last node in the list.
                success = NodeIndex.CreateBefore(this.next.index, out this.index);
            }
            else
            {
                // This node is between two nodes in the list.
                success = NodeIndex.CreateBetween(this.previous.index, this.next.index, out this.index);
            }

            return(success);
        }