Linked list – use the LinkedList class in Smalltalk?
I'm not sure I fully understand how to use the LinkedList class provided by Smalltalk visual works I can create an instance of a class through simple operations:
myList := LinkedList new.
But how do I add nodes I tried to create an instance of the link class and set a value, but it didn't seem to work
myLink := Link new. myLink value: 3.
I am very new to Smalltalk, and any help will be appreciated!
Solution
As a novice instead of learning how to use orderedcollection Then look at the methods of these two classes to see their similarities and differences You will find that they are essentially the same, because the whole difference lies in the performance of inserting and deleting elements in the middle of the collection In the orderedcollection, the entire collection is copied, while in the LinkedList, only the "pointer" applies to the inserted node
In fact, LinkedList is rarely used because orderedcollection is sufficient to meet most, if not all, requirements