Immutable version of EnumSet

Are you looking for Sets.immutableEnumSet (Guava) perhaps? Returns an immutable set instance containing the given enum elements. Internally, the returned set will be backed by an EnumSet. The iteration order of the returned set follows the enum’s iteration order, not the order in which the elements appear in the given collection.

Is there a corresponding immutable enumMap in guava?

Guava contributor here. Guava doesn’t currently have an ImmutableEnumMap variant, but if it did, it would probably just be a wrapper around an EnumMap. (That said, slightly better immutable implementations are possible.) EnumMap will perform better than the basic ImmutableMap, in any event; it’s difficult or impossible to beat. (I’ll file an issue to investigate … Read more

How do laziness and parallelism coexist in Haskell?

Yes, GHC’s RTS uses thunks to implement non-strict evaluation, and they use mutation under the hood, so they require some synchronisation. However, this is simplified due to the fact that most heap objects are immutable and functions are referentially transparent. In a multithreaded program, evaluation of a thunk proceeds as follows: The thunk is atomically† … Read more

what is “failure atomicity” used by J bloch and how its beneficial in terms of immutable object?

Bloch’s “Failure atomicity” means that if a method threw an exception, the object should still be usable afterwards. Generally, the object should be in the same state as it was before invoking the method. In the case of an immutable object, you gain that simply from the fact that it’s immutable. There is no operation … Read more

tech