链表是数据结构中存储数据的一种形式。分为单向链表和双向链表以及循环链表。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. 快速上手virtualenv

    五分钟轻松学会管理项目开发环境. 在开发Python应用程序的时候,系统安装的Python3只有一个版本:3.x.所有第三方的包都会被pip安装到Python3的site-packages目录下. p ...

  2. DocFX生成PDF文档

    使用DocFX生成PDF文档,将在线文档转换为PDF离线文档. 关于DocFX的简单介绍使用DocFX生成文档 使用docfx 命令 1.下载 https://github.com/dotnet/do ...

  3. 【Jquery】之DOM操作

    Questions 本篇文章主要讲解Jquery中对DOM的操作,主要内容如下: 1    内容区 1.1  .addClass() (1).addClass(className) <!DOCT ...

  4. inline-block并列排序时候的影响

    当两个设置了inline-block属性的元素并列排放时,它们的位置能够互相影响. 元素结构: <div class="container"> <div clas ...

  5. springboot+jpa+thymeleaf增删改查的示例(转)

    这篇文章介绍如何使用jpa和thymeleaf做一个增删改查的示例. 先和大家聊聊我为什么喜欢写这种脚手架的项目,在我学习一门新技术的时候,总是想快速的搭建起一个demo来试试它的效果,越简单越容易上 ...

  6. 《编程珠玑(第2版)》【PDF】下载

    <编程珠玑(第2版)>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230382225 内容简介 书的内容围绕程序设计人员面对的一系列实 ...

  7. 引言关于本博客的ES6

    本博客ES6全部取自于阮一峰的<ES6标准入门>里面掺杂着一些node.js,写这些东西是为了让大家更好的去理解这本书,其实更像是一个教材参考,里面有一些是阮一峰先生可能没有考虑到新手的某 ...

  8. ReactNative 基础学习

    安卓Back键的处理·基本+高级篇 http://bbs.reactnative.cn/topic/480/%E5%AE%89%E5%8D%93back%E9%94%AE%E7%9A%84%E5%A4 ...

  9. listbox控件使用

    1. 属性列表: SelectionMode    组件中条目的选择类型,即多选(Multiple).单选(Single)    Rows             列表框中显示总共多少行    Sel ...

  10. ArcGIS API for JavaScript 4.2学习笔记[13] Layer的弹窗(PopupTemplate)

    上一篇文章中讲到Popup是一个弹窗,是View对象的默认内置弹窗,并且在View对象构造时就顺便构造了. 那么这个PopupTemplate是什么呢? 后半截单词Template是"模板& ...