add_nodesToTheList(current, next, changeObject, pointerChange) {
        var addedNodes = next.getLinkedListForStep().LinkedListNodes.filter(comparer(current.getLinkedListForStep().LinkedListNodes));
        for (var i = 0; i < addedNodes.length; i++) {
            var node = addedNodes[i];
            var nodeIndex = next.getLinkedListForStep().getNodeLocation(node.getReference());
            //if this new node is not pointed by any other node, so this node is not in the list
            var partOfTheList = false;
            if(current.getLinkedListForStep().size() > 0){
            var newNodeReference = node.getReference();
            for (var j = 0; j < next.getLinkedListForStep().size(); j++) {
                if (j !== nodeIndex) {
                    if (next.getLinkedListForStep().getNode(j).getNext() !== null &&
                        next.getLinkedListForStep().getNode(j).getNext().toString() === newNodeReference)
                        partOfTheList = true;
                }
            }
            
            if (!partOfTheList) { //means that the node is either will be added at the beginning of the list or the node is separate from the list
                //check to see if the node will be added in the beginning of the list
                var atBeginning = false;
                var node = addedNodes[i];
                if(node.getNext() !== null){
                for (var j = 0; j < next.getLinkedListForStep().size(); j++) {
                    if (j !== nodeIndex) {
                        if (next.getLinkedListForStep().getNode(j).getNext() !== null &&
                            next.getLinkedListForStep().getNode(j).getReference().toString() === node.getNext().toString())
                            atBeginning = true;
                    }
                }
                }
                if (atBeginning) {
                    this.JsavLinkedList.addFirst(node.getData(), node.getReference());

                    this.JsavLinkedList.layout();
                    this.visualizer.umsg("add new node with value " + node.getData() + " at the beginning of the list");
                } else { //means the node is separated from the list
                    var newNode = this.JsavLinkedList.newNode(node.getData());
                    newNode.css({
                        top: +100,
                        left: 0 //first
                    });
                }
                if (pointerChange.hasOwnProperty('reference') && pointerChange.To.toString() === newNodeReference) {
                    if (atBeginning) {
                        this.visualizer.step();
                        this.movePointer(pointerChange.pointerIndex, 0, node.getReference());
                    } else {
                        this.movePointerToSeparateNode(pointerChange.pointerIndex, newNode, newNodeReference);
                    }
                    this.visualizer.umsg("make pointer " + this.pointersForVisualization.getPointer(pointerChange.pointerIndex).getName() + " points to node with value " + node.getData());
                    pointerChange = null; //to prevent re-displaying the pointer latter in this function
                }
            } else {
                this.JsavLinkedList.add(nodeIndex, node.getData(), node.getReference());
                this.visualizer.umsg("Create new Node with data value " + node.getData() + ' and add it to the list at location ' + nodeIndex);
                this.JsavLinkedList.layout();
            }
        }
        else{
            this.JsavLinkedList.add(nodeIndex, node.getData(), node.getReference());
                this.visualizer.umsg("Create new Node with data value " + node.getData() + ' and add it to the list at location ' + nodeIndex);
                this.JsavLinkedList.layout();
        }
        }
        //now if there is a change in pointers we will visualize it
        if (pointerChange !== null) {
            if (pointerChange.hasOwnProperty('reference')) {
                var toIndex = next.getLinkedListForStep().getNodeLocation(pointerChange.To);
                this.visualizer.step();

                this.movePointer(pointerChange.pointerIndex, toIndex, pointerChange.To);
            }
        }
    }
/**
     * Adds a node the the current Visualized linked list and visualize the addition
     * @param {VisualizationStep} current the current visualization step
     * @param {VisualizationStep} next the next visualization step
     * @param {Hash} changeObject Hash table that contains the changes to be applied on list nodes
     * @param {Hash} pointerChange Hash table that contains the changes to be applied on pointers
     */
Adds a node the the current Visualized linked list and visualize the addition
@param {VisualizationStep} current the current visualization step
@param {VisualizationStep} next the next visualization step
@param {Hash} changeObject Hash table that contains the changes to be applied on list nodes
@param {Hash} pointerChange Hash table that contains the changes to be applied on pointers
Adds a node the the current Visualized linked list and visualize the addition @param { VisualizationStep } current the current visualization step @param { VisualizationStep } next the next visualization step @param { Hash } changeObject Hash table that contains the changes to be applied on list nodes @param { Hash } pointerChange Hash table that contains the changes to be applied on pointers
add_nodesToTheList(current, next, changeObject, pointerChange) {
        var addedNodes = next.getLinkedListForStep().LinkedListNodes.filter(comparer(current.getLinkedListForStep().LinkedListNodes));
        for (var i = 0; i < addedNodes.length; i++) {
            var node = addedNodes[i];
            var nodeIndex = next.getLinkedListForStep().getNodeLocation(node.getReference());
            var partOfTheList = false;
            if(current.getLinkedListForStep().size() > 0){
            var newNodeReference = node.getReference();
            for (var j = 0; j < next.getLinkedListForStep().size(); j++) {
                if (j !== nodeIndex) {
                    if (next.getLinkedListForStep().getNode(j).getNext() !== null &&
                        next.getLinkedListForStep().getNode(j).getNext().toString() === newNodeReference)
                        partOfTheList = true;
                }
            }
            if (!partOfTheList) { 
                var atBeginning = false;
                var node = addedNodes[i];
                if(node.getNext() !== null){
                for (var j = 0; j < next.getLinkedListForStep().size(); j++) {
                    if (j !== nodeIndex) {
                        if (next.getLinkedListForStep().getNode(j).getNext() !== null &&
                            next.getLinkedListForStep().getNode(j).getReference().toString() === node.getNext().toString())
                            atBeginning = true;
                    }
                }
                }
                if (atBeginning) {
                    this.JsavLinkedList.addFirst(node.getData(), node.getReference());
                    this.JsavLinkedList.layout();
                    this.visualizer.umsg("add new node with value " + node.getData() + " at the beginning of the list");
                } else { 
                    var newNode = this.JsavLinkedList.newNode(node.getData());
                    newNode.css({
                        top: +100,
                        left: 0 
                    });
                }
                if (pointerChange.hasOwnProperty('reference') && pointerChange.To.toString() === newNodeReference) {
                    if (atBeginning) {
                        this.visualizer.step();
                        this.movePointer(pointerChange.pointerIndex, 0, node.getReference());
                    } else {
                        this.movePointerToSeparateNode(pointerChange.pointerIndex, newNode, newNodeReference);
                    }
                    this.visualizer.umsg("make pointer " + this.pointersForVisualization.getPointer(pointerChange.pointerIndex).getName() + " points to node with value " + node.getData());
                    pointerChange = null; 
                }
            } else {
                this.JsavLinkedList.add(nodeIndex, node.getData(), node.getReference());
                this.visualizer.umsg("Create new Node with data value " + node.getData() + ' and add it to the list at location ' + nodeIndex);
                this.JsavLinkedList.layout();
            }
        }
        else{
            this.JsavLinkedList.add(nodeIndex, node.getData(), node.getReference());
                this.visualizer.umsg("Create new Node with data value " + node.getData() + ' and add it to the list at location ' + nodeIndex);
                this.JsavLinkedList.layout();
        }
        }
        if (pointerChange !== null) {
            if (pointerChange.hasOwnProperty('reference')) {
                var toIndex = next.getLinkedListForStep().getNodeLocation(pointerChange.To);
                this.visualizer.step();
                this.movePointer(pointerChange.pointerIndex, toIndex, pointerChange.To);
            }
        }
    }
add_nodesToTheList ( current , next , changeObject , pointerChange ) { var addedNodes = next . getLinkedListForStep ( ) . LinkedListNodes . filter ( comparer ( current . getLinkedListForStep ( ) . LinkedListNodes ) ) ; for ( var i = 0 ; i < addedNodes . length ; i ++ ) { var node = addedNodes [ i ] ; var nodeIndex = next . getLinkedListForStep ( ) . getNodeLocation ( node . getReference ( ) ) ; var partOfTheList = false ; if ( current . getLinkedListForStep ( ) . size ( ) > 0 ) { var newNodeReference = node . getReference ( ) ; for ( var j = 0 ; j < next . getLinkedListForStep ( ) . size ( ) ; j ++ ) { if ( j !== nodeIndex ) { if ( next . getLinkedListForStep ( ) . getNode ( j ) . getNext ( ) !== null && next . getLinkedListForStep ( ) . getNode ( j ) . getNext ( ) . toString ( ) === newNodeReference ) partOfTheList = true ; } } if ( ! partOfTheList ) { var atBeginning = false ; var node = addedNodes [ i ] ; if ( node . getNext ( ) !== null ) { for ( var j = 0 ; j < next . getLinkedListForStep ( ) . size ( ) ; j ++ ) { if ( j !== nodeIndex ) { if ( next . getLinkedListForStep ( ) . getNode ( j ) . getNext ( ) !== null && next . getLinkedListForStep ( ) . getNode ( j ) . getReference ( ) . toString ( ) === node . getNext ( ) . toString ( ) ) atBeginning = true ; } } } if ( atBeginning ) { this . JsavLinkedList . addFirst ( node . getData ( ) , node . getReference ( ) ) ; this . JsavLinkedList . layout ( ) ; this . visualizer . umsg ( "add new node with value " + node . getData ( ) + " at the beginning of the list" ) ; } else { var newNode = this . JsavLinkedList . newNode ( node . getData ( ) ) ; newNode . css ( { top : + 100 , left : 0 } ) ; } if ( pointerChange . hasOwnProperty ( 'reference' ) && pointerChange . To . toString ( ) === newNodeReference ) { if ( atBeginning ) { this . visualizer . step ( ) ; this . movePointer ( pointerChange . pointerIndex , 0 , node . getReference ( ) ) ; } else { this . movePointerToSeparateNode ( pointerChange . pointerIndex , newNode , newNodeReference ) ; } this . visualizer . umsg ( "make pointer " + this . pointersForVisualization . getPointer ( pointerChange . pointerIndex ) . getName ( ) + " points to node with value " + node . getData ( ) ) ; pointerChange = null ; } } else { this . JsavLinkedList . add ( nodeIndex , node . getData ( ) , node . getReference ( ) ) ; this . visualizer . umsg ( "Create new Node with data value " + node . getData ( ) + ' and add it to the list at location ' + nodeIndex ) ; this . JsavLinkedList . layout ( ) ; } } else { this . JsavLinkedList . add ( nodeIndex , node . getData ( ) , node . getReference ( ) ) ; this . visualizer . umsg ( "Create new Node with data value " + node . getData ( ) + ' and add it to the list at location ' + nodeIndex ) ; this . JsavLinkedList . layout ( ) ; } } if ( pointerChange !== null ) { if ( pointerChange . hasOwnProperty ( 'reference' ) ) { var toIndex = next . getLinkedListForStep ( ) . getNodeLocation ( pointerChange . To ) ; this . visualizer . step ( ) ; this . movePointer ( pointerChange . pointerIndex , toIndex , pointerChange . To ) ; } } }
Adds a node the the current Visualized linked list and visualize the addition
 @param {VisualizationStep} current the current visualization step
 @param {VisualizationStep} next the next visualization step
 @param {Hash} changeObject Hash table that contains the changes to be applied on list nodes
 @param {Hash} pointerChange Hash table that contains the changes to be applied on pointers
Adds a node the the current Visualized linked list and visualize the addition @param { VisualizationStep } current the current visualization step @param { VisualizationStep } next the next visualization step @param { Hash } changeObject Hash table that contains the changes to be applied on list nodes @param { Hash } pointerChange Hash table that contains the changes to be applied on pointers
//if this new node is not pointed by any other node, so this node is not in the list //means that the node is either will be added at the beginning of the list or the node is separate from the list //check to see if the node will be added in the beginning of the list //means the node is separated from the list //first //to prevent re-displaying the pointer latter in this function //now if there is a change in pointers we will visualize it