Base de conocimientosCentro de exámenes
ESEspañol
Elegir idioma13

CKTIS / C#

System.Collections.Generic.SortedSet: referencia práctica

System.Collections.Generic.SortedSet: referencia práctica: SortedSet<T> mantiene elementos únicos en el orden definido por su comparador.

Versión: .NET API; verified on .NET 10.0.14

Sintaxis

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

SortedSet mantiene elementos únicos en el orden definido por su comparador.

Úsalo para conjuntos ordenados y consultas por intervalo que necesiten pertenencia ordenada.

La unicidad se determina con Compare igual a cero y un estado de orden mutable rompe la estructura.

Min y Max dan el valor predeterminado definido por la API en un conjunto vacío; GetViewBetween exige un intervalo válido.

El programa completo usa realmente System.Collections.Generic.SortedSet; su stdout esperado exacto es 1,2,3.

Ejemplos

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

Resultado

1,2,3

El programa completo usa realmente `System.Collections.Generic.SortedSet`; su stdout esperado exacto es `1,2,3`.

Fuentes