CKTIS / C#
System.Collections.Generic.LinkedList: odniesienie praktyczne
System.Collections.Generic.LinkedList: odniesienie praktyczne: LinkedList<T> jest dwukierunkową listą z O(1) wstawieniem/usunięciem znanego węzła.
Wersja: .NET API; verified on .NET 10.0.14
Składnia
System.Collections.Generic.LinkedList /* select a documented member or constructor */LinkedList jest dwukierunkową listą z O(1) wstawieniem/usunięciem znanego węzła.
Stosuj, gdy często przemieszczasz znane węzły i nie potrzebujesz indeksowania.
Wyszukanie wartości jest O(n), a każdy LinkedListNode należy tylko do jednej listy.
First/Last są null dla pustej listy; usunięty węzeł traci List.
Kompletny program rzeczywiście używa System.Collections.Generic.LinkedList; oczekiwany stdout to dokładnie 2,3.
Przykłady
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var list = new LinkedList<int>();
list.AddFirst(2);
list.AddLast(3);
Console.WriteLine($"{list.First!.Value},{list.Last!.Value}");
Wynik
2,3
Kompletny program rzeczywiście używa `System.Collections.Generic.LinkedList`; oczekiwany stdout to dokładnie `2,3`.