Repository navigation
Conversation
| class ProtectedUniqueArrayGene<T>( | ||
| name: String, | ||
| template: T, | ||
| protectedCount: Int? = null, |
There was a problem hiding this comment.
shouldn't this be 0 (no protected elements) by default?
There was a problem hiding this comment.
Given one of the goals of the structure is to protect some elements from mutation, omitting it (while still choosing to use this gene type) assumes the user wants to protect all initial elements. When omitted and set to null, the initialization sets it to elements.size(). If we set it to 0 by default, we can't do that because we don't know if the user omitted it OR set it to 0. Basically it's an opt-out of protection vs an opt-in. My opinion is that the name of the gene is intention revealing so a user should expect protection by default. Anyhow, happy to change the behaviour to opt in if you think it's better that way.
9685908 to
fc20430
Compare
|
@aschenzle hi! recall in PRs to ask @jgaleotti review and, when he is happy with changes, he ll ask for mine ;) |
fc20430 to
1138428
Compare
1138428 to
79ddb02
Compare
…der unique-set mutation
… for rollback and repair.
2f88a6c to
89ba432
Compare
Introduces
ProtectedUniqueArrayGene<T>, anArrayGene<T>specialization (uniqueElements = true) that protects its leadingprotectedCountelements from deletion while still allowing search to mutate their values in place and grow/shrink trailing elements. This supports inferred non-empty set types (such as DynamoDBSSandNS) that must never shrink below their seeded/protected elements while remaining mutable during search.