Znalostná bázaCentrum skúšok
SKSlovenčina
Vybrať jazyk13

CKTIS / C#

System.Collections.Generic.LinkedList: praktická referencia

System.Collections.Generic.LinkedList: praktická referencia: LinkedList<T> je obojsmerne prepojený zoznam s konštantným vložením či odstránením známeho uzla.

Verzia: .NET API; verified on .NET 10.0.14

Syntax

System.Collections.Generic.LinkedList /* select a documented member or constructor */

LinkedList je obojsmerne prepojený zoznam s konštantným vložením či odstránením známeho uzla.

Použite ho, keď často presúvate známe uzly a nepotrebujete náhodný prístup podľa indexu.

Vyhľadanie hodnoty je lineárne a každý LinkedListNode môže súčasne patriť len do jedného zoznamu.

First a Last sú pri prázdnom zozname null a odstránenému uzlu sa vymaže vlastnosť List.

Úplný program skutočne používa System.Collections.Generic.LinkedList; presne očakávaný stdout je 2,3.

Príklady

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}");

Výsledok

2,3

Úplný program skutočne používa `System.Collections.Generic.LinkedList`; presne očakávaný stdout je `2,3`.

Zdroje