using System.Collections;
using System.Collections.Generic;//LinkedList LinkedListNode在该空间
using UnityEngine;
public class 链表 : MonoBehaviour {
//双向链表
LinkedList<int> linList = new LinkedList<int>();
LinkedListNode<int> node;
void Start()
{
node = linList.AddFirst(1);
linList.AddAfter(node, 2);
node= linList.AddBefore(node, 0);
Debug.Log(linList.Count);//3
Debug.Log(linList.First.Value);//0
Debug.Log(linList.Last.Value);//2
if (node.Previous!=null)
{
Debug.Log(node.Previous.Value);//不判断会报错 ERROR:空引用
}
if (node.Next != null)
{
Debug.Log(node.Next.Value);//1
}
}
}
数据结构_链表
最新推荐文章于 2024-04-27 18:39:36 发布