JP
05/24/2020, 10:51 AMKroppeb
05/24/2020, 6:35 PMvalue instead of `\`val\`` so you don't need
* this is a mutable object which you use in SinglyLinkedList meaning that one isn't 'immutable'. One way to fix this would be to have a ListNode and a MutableListNode
* You want this to be either an interface or just don't expose this to the user at all.
On the topic of making a "immutable" and a "mutable" variant, the more correct way to look at it is "mutable vs read only" where read only can still be mutated by other objects (like owners and stuff), although you can often cast them back to the mutable state, this is considered bad practice. To achieve this you correctly made the mutable interface extend the read only one.
`ISinglyLinkedList`:
* In kotlin we don't use the I- prefix unlike in C#. I would like it but it would become really inconsistent when working with java interfaces.
* head and tail are exposed as vars and are therefore mutable
* I don't really see why a tail is provided to the user
* You are providing head and tail as a ListNode. I don't see why a user would ever need to use the node instead of the value itself.
`SinglyLinkedList`:
* the way you implemented isEmpty makes it look like you expect size to be 0 while there is data. This seems wrong to me
* There is no reason for this class to exist
`SinglyLinkedListIteratorImpl`:
I don't think you should have an interface for this one. Implementationwise, I have no idea what you are trying to achieve, and why there is both a currNode and a prevNodeKroppeb
05/24/2020, 6:35 PMJP
05/24/2020, 7:02 PMListNode class with member name like ``val`` . And I was trying to build from that ListNode class.Kroppeb
05/26/2020, 11:26 AMAbstractMutableCollection Adds most implementations using the iterator, which is in a lot of cases way slower as it's almost always at least`O(n)`. So use AbstractMutableCollection in case you don't care about performance and need something quick that doesn't take too much effort to make, or use it and override the methods only when you need them a lot.Kroppeb
05/26/2020, 11:28 AMAbstractMutableCollection is just a kind of helper where the method implementations are often ok but not great.