Back: Link-iteration
Up: Class reference
Forward: LinkedList-accessing
 
Top: GNU Smalltalk User's Guide
Contents: Table of Contents
Index: Class index
About: About this document

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  (instance)
6.88.2 LinkedList: adding  (instance)
6.88.3 LinkedList: enumerating  (instance)
6.88.4 LinkedList: testing  (instance)


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)




This document was generated on May, 12 2002 using texi2html