线性表的链式存储结构-获取指定位置结点元素
//获取指定位置的节点
private Node GetNodeByIndex(int index)
{
    Node go = this._head;
    int i = 0;
    while (go != null && i < index)
    {
        go = go.next;
        i++;
    }
    
    if(i != index)  go = null;

    return go;
}

线性表的链式存储结构


因为是链式结构,不能像数组那样直接下标获取元素了,只能遍历整个链表,一个一个元素往下,知道指定的位置。


首页 我的博客
粤ICP备17103704号