如何在java中使用单个节点类创建不同特征的节点?

时间:2016-03-01 07:27:33

标签: java data-structures nodes

我的节点类是

AsyncCalloutAdapter-22542743: end delegate threw an exception
   System.OperationCanceledException: Operation canceled. --->     System.Runtime.InteropServices.COMException: Operation aborted (Exception from   HRESULT: 0x80004004 (E_ABORT))
   at System.Fabric.Interop.NativeRuntime.IFabricStateReplicator2.EndReplicate(IFabricAsyncOperationContext context)
   at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedCompletedSynchronously)
   --- End of inner exception stack trace ---

我想创建一个包含5个部分的节点:

  1. 存储行号
  2. 存储列号
  3. 存储值
  4. 指向下一行的指针
  5. 指向下一栏的指针

1 个答案:

答案 0 :(得分:0)

您可以将以下类用作具有所需值的节点:

static class Node
    {
        int rowNo;
        int columnNo;
        int value;
        Node next;
        int nextColumnNo;
        Node(int r,int c,int v) 
        {
            rowNo=r;
            columnNo=c;
            value=v;
            next=null;
            nextColumnNo=0;
        }
    }

通过链接在一起使用以下节点:

head = new Node(1,11,11);
Node second = new Node(2,22,22);
Node third = new Node(3,33,33);

head.next=second;
second.next=third;

head.nextColumnNo = second.columnNo;
second.nextColumnNo = third.columnNo;