C#单链表

一、首先写链表规范接口

1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 /// <summary> 8 /// 单链表规范 9 /// </summary> 10 /// <typeparam>节点类型</typeparam> 11 public interface IList<T> 12 { 13 /// <summary> 14 /// 求链表长度 15 /// </summary> 16 /// <returns></returns> 17 int GetLength(); 18 19 /// <summary> 20 /// 清空链表 21 /// </summary> 22 void Clear(); 23 24 /// <summary> 25 /// 判空 26 /// </summary> 27 /// <returns></returns> 28 bool IsEmpty(); 29 30 /// <summary> 31 /// 在表索引位置前面插入节点 32 /// </summary> 33 /// <param>节点数据域</param> 34 /// <param>索引</param> 35 void Insert(T user, int i); 36 37 /// <summary> 38 /// 根据索引查询节点 39 /// </summary> 40 /// <param>索引</param> 41 /// <returns></returns> 42 T GetUserByIndex(int i); 43 44 /// <summary> 45 /// 根据节点查询索引 46 /// </summary> 47 /// <param>节点</param> 48 /// <returns></returns> 49 int GetIndexByUser(T user); 50 51 52 ///// <summary> 53 ///// 添加节点 54 ///// </summary> 55 ///// <param>节点数据域</param> 56 //void Append(T name); 57 58 /// <summary> 59 /// 删除索引位置的节点 60 /// </summary> 61 /// <param>索引</param> 62 /// <returns></returns> 63 T Delete(int i); 64 }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpfzjf.html