CKTIS / C#
System.Collections.Frozen.FrozenSet: praktická referencia
System.Collections.Frozen.FrozenSet: praktická referencia: FrozenSet<T> je nemenná množina optimalizovaná po zostavení na opakované kontroly Contains.
Verzia: .NET 8+; verified on .NET 10.0.14
Syntax
System.Collections.Frozen.FrozenSet /* select a documented member or constructor */FrozenSet je nemenná množina optimalizovaná po zostavení na opakované kontroly Contains.
Použite ju pre stabilné zoznamy povolení, množiny kľúčových slov alebo iné často zisťované údaje členstva.
Comparer je pevný a príprava môže pri malých či krátkodobých množinách stáť viac než prínos.
Zostavenie odstráni duplicity, kým zmena objektu použitého ako kľúč môže porušiť uložené predpoklady hashu.
Úplný program skutočne používa System.Collections.Frozen.FrozenSet; presne očakávaný stdout je True.
Príklady
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[] { "a", "b" }.ToFrozenSet();
Console.WriteLine(set.Contains("b"));
Výsledok
True
Úplný program skutočne používa `System.Collections.Frozen.FrozenSet`; presne očakávaný stdout je `True`.