97 questions
3 votes
3 answers
375 views
Are there Immutable Collection classes in .NET that don't have mutation functions?
I am looking for some immutable collections in C#, specifically, a List/array type one, and a set/hashset type one. I'm clarifying if there are 'built in' .NET types that do what I want (I realize ...
4 votes
1 answer
93 views
System.InvalidOperationException: Collection was modified; enumeration operation may not execute for ImmutableDictionary
I have a function that is being repeatedly called via a thread. Randomly some times it raises this exception. System.InvalidOperationException: Collection was modified; enumeration operation may not ...
0 votes
0 answers
58 views
Immutable dictionary property initialization in C# [duplicate]
I've lost several days trying to debug an issue that boils down to this: Properties of type IImmutableDictionary can appear to be initialized in code but actually remain empty. Why is the compiler ...
6 votes
2 answers
531 views
How to show "CA1806: Do not ignore method results" for ImmutableList<T>.Add?
Is there a way to show a warning when you call ImmutableList<T>.Add but don't use its result? I thought CA1806 would do that, and it does for some methods that return results (like string....
2 votes
1 answer
113 views
How to cast ImmutableArray<DerivedClass> to ImmutablyArray<BaseClass> and vice versa in C#?
I know it's not possible to cast derived lists (why not is nicely explained here), but what about ImmutableArrays as they cannot be changed casting should be valid, right? I would expect this to work: ...
0 votes
1 answer
105 views
java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.builder()Lcom/google/common/collect/ImmutableSet$Builder
I'm getting this error continuously Failed to execute goal deploy: {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" =>...
1 vote
2 answers
252 views
Why isn't there an IImmutableArray<T> interface in the .NET Framework?
In the .NET Framework, there are interfaces for immutable dictionaries, lists, queues, sets, stacks. But there is no interface for immutable arrays to be found. Also, immutable arrays are implemented ...
2 votes
2 answers
183 views
What is the difference between ImmutableArray<T>.As<TOther> and ImmutableArray<T>.CastArray<TOther> methods?
I'm trying to understand the exact difference between the 3 following methods of the ImmutableArray struct: the static method ImmutableArray<T>.CastUp<TDerived> the instance method ...
2 votes
2 answers
271 views
Guava - Collect values extracted from two Optionals into an ImmutableSet
I am looking to avoid multiple if-else conditions. Is there a more concise way of writing the below code? private Set<String> getValues(Optional<String> one, Optional<String> two) { ...
0 votes
1 answer
1k views
Differences between ways of creating ImmutableList [closed]
What is the differences between ways of creating ImmutableList? List<int> numbers = new List<int>(){0, 1, 2, 3}; ImmutableList<int> immutableList = numbers.ToImmutableList(); ...
1 vote
1 answer
242 views
Implement Iterable in an immutable LinkedList in Kotlin
I'm trying to understand the functional programming paradigm so I'm playing around with an immutable linked list. I've created a Bag with some utility functions and now I want to iterate through the ...
0 votes
1 answer
75 views
implementing immutable stack in python
Have a question about creating new objects using existing objects in python. Example: I want to implement immutable Stack using python. However, catch here is, whenever I am creating new object, it ...
1 vote
0 answers
702 views
How to solve error "scala.collection.mutable.WrappedArray$ofRef cannot be cast to [Ljava.lang.String" for unwrapping map in UDF
I get the error above when I apply my UDF, which is defined as followed: import org.apache.spark.sql.functions.typedLit import org.apache.spark.sql.functions.udf def method_name(map:Map[String, Array[...
1 vote
2 answers
669 views
Supporting collection initialization syntax for immutable collections - init modifiers for methods?
I need to implement an immutable collection which supports collection initialization syntax. The problem is in order to support collection initialization syntax, the collection must provide ...
0 votes
1 answer
598 views
Immutable vs Concurrent Collections
In the thread When immutable collections are preferable then concurrent it is stated that immutable collections may be slower but they save memory. How is it possible if every change of immutable ...