Questions tagged [immutable-collections]

Immutable Collections is a library containing immutable data structures created by Microsoft for .NET.

Immutable Collections is a library containing immutable data structures created by Microsoft for .NET.

Related tags

93 questions
0
votes
2 answers

How to add elements to CopyInWriteCollection using Kotlin style?

Assume we have a custom collection class CopyOnWriteCollection { // returns copy of collection with new element fun add(element: T): CopyOnWriteCollection { ... } } if i need to add several elements i would do something like…
Bukharov Sergey
  • 9,767
  • 5
  • 39
  • 54
0
votes
1 answer

scala.collection.immutable.Vector cannot be cast to

I am perplexed why I cannot yield a collection from the following line of Scala code: val pairs = for( v <- vc; o <- oc) yield (v,o) It's inside of this function, which is using immutable Vectors. private def recMergeVirtualAndReal(mCell: RCell,…
0
votes
2 answers

Constructor for class with readonly field of immutable storage

Let's say we have the following simple class. Note that the only field is readonly and is for an ImmutableList: class Abc { readonly ImmutableList elts; public Abc(params int[] ls) => elts = ImmutableList.CreateRange(ls); } Given…
dharmatech
  • 8,979
  • 8
  • 42
  • 88
0
votes
1 answer

Which is the best way to create an empty set in builder object

A class has a Set of String objects defined as its instance variable. Step-1: I have a method which creates an object for this class, assign an empty set of String to the instance variable and then returns the object. The method which receives it,…
adimoh
  • 658
  • 2
  • 8
  • 20
0
votes
1 answer

C# - Where are the immutable collections?

I'm reading a book and it introduces me to immutable collections which includes ImmutableDictionary, ImmutableHashSet and more. The book says that its in Microsoft.Bcl.Immutable NuGet package but I can't find it. Any help? Also, I'm using .NET…
Marc2001
  • 281
  • 1
  • 3
  • 12
0
votes
1 answer

How to add parameters to request.form in Flask

How can I add an object like {'client_id':'...', 'grant_type':'...'} to request.form in Flask ? I know request.form is immutable, but I need to do this because the method I need to use (from oauth) just accepts request.form, if I pass .json it…
user7075574
0
votes
1 answer

Recursion in scala wont stop

I have a method which helps me to solve a knight's tour. I want my recursion to stop as soon as I have found a solution however It keeps going on and on. At the end it returns nearly 20 different solutions. I have added my code below, Can Someone…
Siyavash
  • 970
  • 9
  • 23
0
votes
1 answer

Service Fabric: ImmutableList stored in IReliableDictionary returning empty when application upgrades

I am currently working on a Service Fabric stateful service that keeps several IReliableDictionary objects. Some of these dictionaries have ImmutableLists as values, as recommended by this article. For example, I have an…
Alex F
  • 223
  • 2
  • 6
0
votes
2 answers

Not able to make the value types inside a structure as mutable in c#

I am converting VB6 codes to C# Here I have to convert array of struct into List approach in c# but not able to modify the value in the below sample code getting error as "Cannot modify the return value of…
Yogeswaran K
  • 51
  • 2
  • 9
0
votes
0 answers

How to setup an ImmutableList with Auto-Value?

I try to setup an immutable list with Auto-Value. I followed the offical user-guide which recommends to implement something like that: @AutoValue public abstract class ListExample { public static ListExample create(String[] mutableNames) { …
GaborH
  • 689
  • 2
  • 11
  • 24
0
votes
3 answers

Immutable Scala Collection

I have this Scala code that spits out unique random numbers for the Italian lottery: object Enalotto { def main(args: Array[String]): Unit = { val numbers = scala.collection.mutable.SortedSet[Int]() val r = scala.util.Random …
0
votes
0 answers

Change C# System.Numerics.Vector to mutable?

I am considering using System.Numerics.Vector in my C# project which involves lots of math computations. The main thing this package attracts me is the hardware accelerated feature. However, the data structure is said to be immutable whereas in my…
0
votes
2 answers

C# returning Dictionary references safely

I'm considering three approaches for returning references to internal Dictionary instances (C#) in regards to code safety and impact on the code readability/visually for a project I'm working on. I've narrowed it down to the following three…
Syntax
  • 2,155
  • 2
  • 23
  • 34
0
votes
1 answer

Error trying to map ImmutableDictionary with AutoMapper

I want to map a POCO into an ImmutableDictionary and Automapper is raising an exception because the Add operation is not supported in ImmutableDictionary. The POCO object is in a property called Data in the source type that gets…
Carlos G.
  • 4,564
  • 4
  • 34
  • 57
0
votes
1 answer

Difference on concatenation for immutable list between java Guava and Scala

I am trying spark with java and I get stuck by the immutable collections in java. As I understand in Scala when two immutable lists are combined, no deep copy happens. However the available immutable list in java, like guava, does the defensive…
Vulcann
  • 177
  • 12