Baza znanjaIzpitno središče
SLSlovenščina
Izberi jezik13

CKTIS / C#

System.Collections.Generic.SortedSet: praktična referenca

System.Collections.Generic.SortedSet: praktična referenca: SortedSet<T> ohranja enolične elemente v vrstnem redu, ki ga določa comparer.

Različica: .NET API; verified on .NET 10.0.14

Sintaksa

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

SortedSet ohranja enolične elemente v vrstnem redu, ki ga določa comparer.

Uporabite ga za urejene množice in poizvedbe po obsegu, ki potrebujejo urejeno članstvo.

Enoličnost določa Compare z vrednostjo nič, spremenljivo stanje urejanja pa krši podatkovno strukturo.

Min in Max za prazno množico vrneta privzeto vrednost API; GetViewBetween zahteva veljaven obseg.

Celoten program dejansko uporabi System.Collections.Generic.SortedSet; natančno pričakovani stdout je 1,2,3.

Primeri

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

Rezultat

1,2,3

Celoten program dejansko uporabi `System.Collections.Generic.SortedSet`; natančno pričakovani stdout je `1,2,3`.

Viri