Linked list 二维数组链表

Linked list 二维数组链表,linked-list,Linked List,任何关于我做错了什么的暗示在过去的三天里,我一直在试图弄清楚这一点。我的节点应该指向下方和右侧。对于我的2d数组矩阵。这是我的节点类,这是我的方法。只要让我知道我是否在正确的轨道上,或者我是否偏离了方向。谢谢 public class Array2DNode<E> { public E item; protected Array2DNode<E> nextRow=null; protected Array2DNode<E> nextCo

任何关于我做错了什么的暗示在过去的三天里,我一直在试图弄清楚这一点。我的节点应该指向下方和右侧。对于我的2d数组矩阵。这是我的节点类,这是我的方法。只要让我知道我是否在正确的轨道上,或者我是否偏离了方向。谢谢

public class Array2DNode<E> {
    public E item;
    protected Array2DNode<E> nextRow=null;
    protected Array2DNode<E> nextCol=null;


    public Array2DNode(){

    }

    public Array2DNode(E item){
        this.item = item;
        this.nextRow = null;
        this.nextCol = null;


    }


}


   public Array2D(E[][] array) {

        this.rows = array.length;
        this.cols = array[0].length;

        int countNextRow = 0;
        int countNextCol = 0;


        while (head == null) {
            Array2DNode arrayNode= new Array2DNode(array[countNextRow][countNextCol]);
            this.head = arrayNode;
            this.rowTail = arrayNode;
            this.colTail = arrayNode;
        }


        //this links everything vertically
        for (countNextCol = 0; countNextCol < cols; countNextCol++) {
            for (countNextRow = 0; countNextRow < rows; countNextRow++) {
                if (countNextRow == 0 && countNextCol == 0) {
                    //do nothing
                } else {
                    Array2DNode arrayNode = new Array2DNode<>(array[countNextRow][countNextCol]); //1,0
                    this.rowTail.nextRow = arrayNode;
                    this.rowTail = arrayNode;
                }
            }
        }

        //this links everything horizontally
        for (countNextRow = 0; countNextRow < rows; countNextRow++) {
            for (countNextCol = 0; countNextCol < cols; countNextCol++) {
                if (countNextRow == 0 && countNextCol == 0) {
                    //do nothing
                } else {
                    Array2DNode arrayNode = new Array2DNode<>(array[countNextRow][countNextCol]); //1,0
                    this.colTail.nextCol = arrayNode;
                    this.colTail = arrayNode;
                }
            }
        }

        
    }
公共类Array2DNode{
公共电子项目;
受保护的Array2DNode nextRow=null;
受保护的Array2DNode nextCol=null;
公共Array2DNode(){
}
公共阵列2dnode(E项){
this.item=项目;
this.nextRow=null;
this.nextCol=null;
}
}
公共阵列2d(E[][]阵列){
this.rows=array.length;
this.cols=数组[0]。长度;
int countNextRow=0;
int countNextCol=0;
while(head==null){
Array2DNode arrayNode=新的Array2DNode(数组[countNextRow][countNextCol]);
this.head=arrayNode;
this.rowTail=arrayNode;
this.colTail=arrayNode;
}
//这将垂直链接所有内容
for(countNextCol=0;countNextCol