CKTIS / C#
System.Collections.Immutable.ImmutableHashSet: praktická referencia
System.Collections.Immutable.ImmutableHashSet: praktická referencia: ImmutableHashSet<T> po účinnom Add alebo Remove vráti novú verziu množiny.
Verzia: .NET API; verified on .NET 10.0.14
Syntax
System.Collections.Immutable.ImmutableHashSet /* select a documented member or constructor */ImmutableHashSet po účinnom Add alebo Remove vráti novú verziu množiny.
Použite ho pre nemenné množiny členstva bezpečne zdieľané medzi viacerými čitateľmi.
Operácia bez zmeny môže vrátiť rovnakú inštanciu a referenčné objekty prvkov sa nezmrazia.
Jedinečnosť a spracovanie null určuje comparer; meniteľný stav hashu zostáva chybou.
Úplný program skutočne používa System.Collections.Immutable.ImmutableHashSet; presne očakávaný stdout je 1.
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 = ImmutableHashSet<int>.Empty.Add(1).Add(1);
Console.WriteLine(set.Count);
Výsledok
1
Úplný program skutočne používa `System.Collections.Immutable.ImmutableHashSet`; presne očakávaný stdout je `1`.