链表是数据结构中存储数据的一种形式。分为单向链表和双向链表以及循环链表。LinkedList是泛型链表,用节点存取,节点类型为LinkedListNode<T>,每个节点都有Next和Previous属性,这就说明LinkedList是双向链表。链表的优点就是节省内存空间,每个节点包括两部分:数据域和指针域。每个节点相连,添加几个节点就占用几个节点的内存。

初始化:

LinkedList<int> intList = new LinkedList<int>();

添加一个新值到链表的开始:

intList.AddFirst(1);

添加一个新值到链表的结尾:

intList.AddLast(1);

获取第一个节点:

LinkedListNode<int> firstNode = intList.First;

获取最后一个节点:

LinkedListNode<int> lastNode = intList.Last;

在最后一个节点插入一个新值:

intList.AddBefore(lastNode, 3);

判断一个值是否存在:

intList.Contains(1);

查找指定值所在的节点:

LinkedListNode<int> node = intList.Find(1);

移除一个指定的值:

bool b = intList.Remove(1);

删除最开始的节点:

intList.RemoveFirst();

删除最后的节点:

intList.RemoveLast();

获取链表的节点数:

int count = intList.Count;

遍历链表:

foreach (var item in intList)
{
    //TODO Something
}

linked lists in .NET的更多相关文章

  1. [LeetCode] Intersection of Two Linked Lists 求两个链表的交点

    Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...

  2. 【leetcode】Intersection of Two Linked Lists

    题目简述: Write a program to find the node at which the intersection of two singly linked lists begins. ...

  3. [LintCode] Intersection of Two Linked Lists 求两个链表的交点

    Write a program to find the node at which the intersection of two singly linked lists begins. Notice ...

  4. Intersection of Two Linked Lists

    Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...

  5. Leetcode 160. Intersection of two linked lists

    Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...

  6. (LinkedList)Intersection of Two Linked Lists

    Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...

  7. Java for LeetCode 160 Intersection of Two Linked Lists

    Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...

  8. [leetCode][003] Intersection of Two Linked Lists

    [题目]: Write a program to find the node at which the intersection of two singly linked lists begins. ...

  9. LeetCode Intersection of Two Linked Lists

    原题链接在这里:https://leetcode.com/problems/intersection-of-two-linked-lists/ 思路:1. 找到距离各自tail 相同距离的起始List ...

  10. 160. Intersection of Two Linked Lists

    Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...

随机推荐

  1. Android自己定义组件之日历控件-精美日历实现(内容、样式可扩展)

    需求 我们知道.Android系统本身有自带的日历控件,网络上也有非常多开源的日历控件资源.可是这些日历控件往往样式较单一.API较多.不易于在实际项目中扩展并实现出符合详细样式风格的,内容可定制的效 ...

  2. 服务器固件测试--PCI设备的介绍(集成网卡和外插网卡)

    今天2017年9月26号,快三个月的时间,是该梳理一下,我来到这个岗位学到的东西. 网卡是什么 网卡分为俩大类 板载的集成网卡和外插的网卡.外插的网卡又分为很多种. 板载的集成网卡 外插的网卡分为 I ...

  3. MPSOC之5——开发流程BOOT.BIN

    需要把若干文件打成大包,烧写到flash或者sd卡中,才能启动运行. 1.petalinux打包 petalinux-packet打包时,需要petalinux的工程,限制太死了,不用. 2 wind ...

  4. 让你高效的理解JavaScript中的同步、异步和事件循环

    "同步请求","异步请求"相信这两词在程序猿的世界中频频出现,到底是词性的妖娆,还是撸代码的基础要求,下面直接分享本人学习的好东西,保证让你深入浅出,爽得不要不 ...

  5. 使用node的fs读取文件

    啊啊啊啊啊啊啊啊啊啊啊啊啊啊,被node的fs坑了一下午,我又爬上来了,要坚强的笑着活下去,嗯,没毛病老铁. let http = require('http'); let fs = require( ...

  6. Principle-初步认识(简介)

    Principle官网 探究了一下 . 呃--作出了下边这玩意 做的好的是这样的,瞬间把自己给菜了,给大家看看,设计需要UI功夫啊 把这个用上你的界面就搞基了,图形在水平.垂直上的动态效果(*.*) ...

  7. MySQL操作时间的函数集

    求两个Timestamp之间的秒差值: select TIMESTAMPDIFF(SECOND,TIMESTAMP("2017-03-01 07:58:20"),timestamp ...

  8. 利用generator自动生成model(实体)、dao(接口)、mapper(映射)

    1 在MySQL数据库中创建相应的表 /* Navicat MySQL Data Transfer Source Server : 虚拟机_zeus01 Source Server Version : ...

  9. 微信小程序如何开发制作

    微信小程序如何开发制作 微容SMO是一款微信小程序的免费在线制作工具,用户在微容平台上无需编辑代码,可通过拖拽式操作即可完成小程序的制作,真正意义上实现了小程序零代码免费制作! 消除技术门槛:无需代码 ...

  10. (通用)深度学习环境搭建:tensorflow安装教程及常见错误解决

    区别于其他入门教程的"手把手式",本文更强调"因"而非"果".我之所以加上"通用"字样,是因为在你了解了这个开发环境之后 ...