Replies: 1 comment
-
Adding default interface implementation to the core interfaces is never an easy work. Previous attempts have caused some breakings in the whole toolchain. |
Beta Was this translation helpful? Give feedback.
0 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
I'm curious why
IReadOnlyCollection<T>
did not includeCopyTo
method similar toICollection<T>
. To me, this significantly reduces the usefulness ofIReadOnlyCollection<T>
versusIEnumerable<T>
, being that the former still requires the use of the latter to extract data from the underlying object. With the ability to add default implementations, this functionality could easily be added without affecting existing codebase:Thus enabling optimization of classes that consume
IReadOnlyCollection<T>
for enumeration. For example, I created a generic undo/redo stack implementation that is anIReadOnlyCollection<T>
. (See UndoRedoStack.) When initializing one stack from another, the only optimization I can achieve is to useIReadOnlyCollection<T>
'sCount
property to initialize the array size and then enumerate through the collection, unlike with anICollection<T>
whereCopyTo
implements a far more efficient copy method.Beta Was this translation helpful? Give feedback.
All reactions