CKTIS / C#
System.Collections.Frozen.FrozenSet: odniesienie praktyczne
System.Collections.Frozen.FrozenSet: odniesienie praktyczne: FrozenSet<T> jest niezmiennym zbiorem zoptymalizowanym pod Contains po zakończeniu budowy.
Wersja: .NET 8+; verified on .NET 10.0.14
Składnia
System.Collections.Frozen.FrozenSet /* select a documented member or constructor */FrozenSet jest niezmiennym zbiorem zoptymalizowanym pod Contains po zakończeniu budowy.
Stosuj dla stabilnych zestawów sprawdzanych wielokrotnie.
Komparator jest utrwalony, a koszt przygotowania może przewyższyć zysk dla małych lub krótkotrwałych zbiorów.
Budowa deduplikuje wartości; późniejsza mutacja obiektu-klucza może zepsuć założenia skrótu.
Kompletny program rzeczywiście używa System.Collections.Frozen.FrozenSet; oczekiwany stdout to dokładnie True.
Przykłady
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"));
Wynik
True
Kompletny program rzeczywiście używa `System.Collections.Frozen.FrozenSet`; oczekiwany stdout to dokładnie `True`.