Baza wiedzyCentrum egzaminacyjne
PLPolski
Wybierz język13

CKTIS / C#

System.Collections.Generic.SortedSet: odniesienie praktyczne

System.Collections.Generic.SortedSet: odniesienie praktyczne: SortedSet<T> utrzymuje unikalne elementy w porządku komparatora.

Wersja: .NET API; verified on .NET 10.0.14

Składnia

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

SortedSet utrzymuje unikalne elementy w porządku komparatora.

Stosuj do posortowanych zbiorów i zapytań zakresowych.

Unikalność wynika z Compare==0; mutable ordering state narusza strukturę.

Min/Max mają wartość domyślną dla pustego zbioru zgodnie z API; GetViewBetween wymaga poprawnego zakresu.

Kompletny program rzeczywiście używa System.Collections.Generic.SortedSet; oczekiwany stdout to dokładnie 1,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 set = new SortedSet<int> { 3, 1, 2 };
Console.WriteLine(string.Join(",", set));

Wynik

1,2,3

Kompletny program rzeczywiście używa `System.Collections.Generic.SortedSet`; oczekiwany stdout to dokładnie `1,2,3`.

Źródła