|
|
6.88 LinkedList
- Defined in namespace Smalltalk
- Category: Collections-Sequenceable
- I provide methods that access and manipulate linked lists. I assume that
the elements of the linked list are subclasses of Link, because I use
the methods that class Link supplies to implement my methods.
6.88.1 LinkedList: accessing
- at: index
- Return the element that is index into the linked list.
- at: index put: object
- This method should not be called for instances of this class.
6.88.2 LinkedList: adding
- add: aLink
- Add aLink at the end of the list; return aLink.
- addFirst: aLink
- Add aLink at the head of the list; return aLink.
- addLast: aLink
- Add aLink at then end of the list; return aLink.
- remove: aLink ifAbsent: aBlock
- Remove aLink from the list and return it, or invoke aBlock if it's not found in the list.
- removeFirst
- Remove the first element from the list and return it, or error if the list is empty.
- removeLast
- Remove the final element from the list and return it, or error if the list is empty.
6.88.3 LinkedList: enumerating
- do: aBlock
- Enumerate each object in the list, passing it to aBlock (actual behavior might depend on the subclass of Link that is being used).
6.88.4 LinkedList: testing
- isEmpty
- Returns true if the list contains no members
- notEmpty
- Returns true if the list contains at least a member
- size
- Answer the number of elements in the list. Warning: this is O(n)
|