Base di conoscenzaCentro esami
ITItaliano
Scegli la lingua13

CKTIS / C#

System.Collections.Generic.SortedSet: riferimento pratico

System.Collections.Generic.SortedSet: riferimento pratico: SortedSet<T> mantiene elementi univoci nell’ordine definito dal comparer.

Versione: .NET API; verified on .NET 10.0.14

Sintassi

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

SortedSet mantiene elementi univoci nell’ordine definito dal comparer.

Usalo per insiemi ordinati e query su intervalli che richiedono appartenenza ordinata.

L’unicità è determinata da Compare uguale a zero e uno stato di ordinamento mutabile viola la struttura.

Min e Max forniscono il valore predefinito dell’API per un insieme vuoto; GetViewBetween richiede un intervallo valido.

Il programma completo usa realmente System.Collections.Generic.SortedSet; lo stdout esatto atteso è 1,2,3.

Esempi

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

Risultato

1,2,3

Il programma completo usa realmente `System.Collections.Generic.SortedSet`; lo stdout esatto atteso è `1,2,3`.

Fonti