linked lists in .NET
链表是数据结构中存储数据的一种形式。分为单向链表和双向链表以及循环链表。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的更多相关文章
- [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 ...
- 【leetcode】Intersection of Two Linked Lists
题目简述: Write a program to find the node at which the intersection of two singly linked lists begins. ...
- [LintCode] Intersection of Two Linked Lists 求两个链表的交点
Write a program to find the node at which the intersection of two singly linked lists begins. Notice ...
- Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...
- 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 ...
- (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 ...
- 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 ...
- [leetCode][003] Intersection of Two Linked Lists
[题目]: Write a program to find the node at which the intersection of two singly linked lists begins. ...
- LeetCode Intersection of Two Linked Lists
原题链接在这里:https://leetcode.com/problems/intersection-of-two-linked-lists/ 思路:1. 找到距离各自tail 相同距离的起始List ...
- 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 ...
随机推荐
- Liunx的常用命令
常用指令 ls 显示文件或目录 -l 列出文件详细信息l(list) -a 列出当前目录下所有文件及目录,包括隐藏的a(all) mkdir 创建目录 -p 创建目录,若无父目录,则创建p(paren ...
- Python datatime 格式转换,插入MySQL数据库
Python datatime 格式转换,插入MySQL数据库 zoerywzhou@163.com http://www.cnblogs.com/swje/ 作者:Zhouwan 2017-11-2 ...
- NanUI 0.4.4发布
NanUI是一个基于ChromiumFX开源项目的.Net Winform界面库,ChromiumFX是Chromium Embedded Framework的.Net实现.众所周知,Chromium ...
- mybatis中#和$符号的区别(转)
mybatis做为一个轻量级ORM框架在许多项目中使用,因其简单的入门受到了广大开发者的热爱.在近期项目中再做一个相关的开发,碰到了#.$符号这样的问题,之前没怎么注意过,通过学习之后,有了点感悟,分 ...
- MVC系列——一个异常消息传递引发的思考
前言:最近在某个项目里面遇到一个有点纠结的小问题,经过半天时间的思索和尝试,问题得到解决.在此记录一下解决的过程,以及解决问题的过程中对.net里面MVC异常处理的思考.都是些老生常谈的问题,不多说, ...
- 商城项目回顾整理(二)easyUi数据表格使用
后台主页: 商品的数据表格展示 引入用户表数据表格展示 引入日志表数据表格展示 引入订单表数据表格展示 后台主页代码: <%@ page language="java" co ...
- IDA分析脱壳后丢失导入表的PE
1. 问题 一些程序经过脱壳后(如用OD的dump插件),一些导入表信息丢失了,导致拖入IDA后看不到API的信息(如右图所示,第一个红圈处实际是GetCurrentProcessId),给分析造成极 ...
- SQL奇技淫巧
1.SQL行列转换 问题:假设有张学生成绩表(tb)如下:姓名 课程 分数张三 语文 74张三 数学 83张三 物理 93李四 语文 74李四 数学 84李四 物理 94想变成(得到如下结果): 姓名 ...
- 一起学Linux04之Linux文件基本属性
Linux系统是一种典型的多用户系统,不同的用户处于不同的地位,拥有不同的权限.为了保护系统的安全性,Linux系统对不同的用户访问同一文件(包括目录文件)的权限做了不同的规定. 为了介绍文件属性,首 ...
- libcurl的使用
http://blog.csdn.net/ixiaochouyu/article/details/47998267