CKTIS / C#
System.Collections.Generic.SortedSet: practical reference
System.Collections.Generic.SortedSet: practical reference: SortedSet<T> keeps unique elements in the order defined by its comparer.
Version: .NET API; verified on .NET 10.0.14
Syntax
System.Collections.Generic.SortedSet /* select a documented member or constructor */SortedSet keeps unique elements in the order defined by its comparer.
Use it for sorted sets and range queries that need ordered membership.
Uniqueness is determined by Compare returning zero, and mutable ordering state violates the data structure.
Min and Max yield the API-defined default for an empty set, while GetViewBetween requires a valid ordered range.
The complete program actually uses System.Collections.Generic.SortedSet; its exact expected stdout is 1,2,3.
Examples
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));
Result
1,2,3
The complete program actually uses `System.Collections.Generic.SortedSet`; its exact expected stdout is `1,2,3`.