Exemplo n.º 1
0
        /// <summary>
        /// Add a new Node to the list.
        /// </summary>
        public void Add(NPOI_Node content)
        {
            size++;
            Node tempCurrent = current;

            var rowTypeString = HelpersMethods.StringArrayToString(content.Cells.Select(x => x.CellType.ToString()).ToArray());

            var rowValueString = HelpersMethods.StringArrayToString(content.Cells.Select(x => HelpersMethods.GetICellStringValue(x)).ToArray());

            var typeHash   = HelpersMethods.GetMD5(Encoding.ASCII.GetBytes(rowTypeString));
            var valuesHash = HelpersMethods.GetMD5(Encoding.ASCII.GetBytes(rowValueString));

            // This is a more verbose implementation to avoid adding nodes to the head of the list
            var node = new Node()
            {
                NodeContent = content,
                TypesHash   = typeHash,
                ValuesHash  = valuesHash
            };

            if (head == null)
            {
                // This is the first node. Make it the head
                head = node;
            }
            else
            {
                // This is not the head. Make it current's next node.
                current.Next  = node;
                node.Previous = tempCurrent;
            }

            // Makes newly added node the current node
            current = node;


            // This implementation is simpler but adds nodes in reverse order. It adds nodes to the head of the list

            //head = new Node()
            //{
            //    Next = head,
            //    NodeContent = content
            //};
        }