CKTIS / C#
System.Collections.Immutable.ImmutableHashSet: praktična referenca
System.Collections.Immutable.ImmutableHashSet: praktična referenca: ImmutableHashSet<T> po učinkovitem Add ali Remove vrne novo različico množice.
Različica: .NET API; verified on .NET 10.0.14
Sintaksa
System.Collections.Immutable.ImmutableHashSet /* select a documented member or constructor */ImmutableHashSet po učinkovitem Add ali Remove vrne novo različico množice.
Uporabite ga za nespremenljive množice članstva, varno deljene med več bralci.
Operacija brez spremembe lahko vrne isto instanco, referenčni objekti elementov pa niso zamrznjeni.
Enoličnost in obravnavo null določa comparer; spremenljivo stanje hasha ostaja napaka.
Celoten program dejansko uporabi System.Collections.Immutable.ImmutableHashSet; natančno pričakovani stdout je 1.
Primeri
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 = ImmutableHashSet<int>.Empty.Add(1).Add(1);
Console.WriteLine(set.Count);
Rezultat
1
Celoten program dejansko uporabi `System.Collections.Immutable.ImmutableHashSet`; natančno pričakovani stdout je `1`.