База знанияИзпитен център
BGБългарски
Избери език13

CKTIS / C#

System.Collections.Immutable.ImmutableHashSet: практическа справка

System.Collections.Immutable.ImmutableHashSet: практическа справка: ImmutableHashSet<T> връща нова версия на множеството след действителен Add или Remove.

Версия: .NET API; verified on .NET 10.0.14

Синтаксис

System.Collections.Immutable.ImmutableHashSet /* select a documented member or constructor */

ImmutableHashSet връща нова версия на множеството след действителен Add или Remove.

Използвайте го за неизменими множества за членство, безопасно споделяни между много читатели.

Операция без промяна може да върне същата инстанция и референтните обекти на елементите не се замразяват.

Уникалността и обработката на null следват comparer; изменяемото хеш състояние остава грешка.

Пълната програма действително използва System.Collections.Immutable.ImmutableHashSet; точният очакван stdout е 1.

Примери

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);

Резултат

1

Пълната програма действително използва `System.Collections.Immutable.ImmutableHashSet`; точният очакван stdout е `1`.

Източници