*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Wed, 15 Feb 2006 15:37:34 +0100
changeset 9117 62e21d3b40e2
parent 9116 4f4898011dd5
child 9118 192331be0626
*** empty log message ***
LinkedList.st
--- a/LinkedList.st	Wed Feb 15 14:51:31 2006 +0100
+++ b/LinkedList.st	Wed Feb 15 15:37:34 2006 +0100
@@ -146,15 +146,25 @@
      Notice, that many methods in SeqColl are based on at:-access,
      so other inherited methods may be very slow (showing square runtime)."
 
+    ^ self at:index ifAbsent:[ self subscriptBoundsError:index]
+!
+
+at:index ifAbsent:exceptionBlock
+    "return the n'th element - use of this method should be avoided,
+     since it is slow to walk through the list - think about using
+     another collection if you need index access.
+     Notice, that many methods in SeqColl are based on at:-access,
+     so other inherited methods may be very slow (showing square runtime)."
+
     |theLink
      runIndex "{Class: SmallInteger}"|
 
     theLink := firstLink.
     runIndex := 1.
     [runIndex == index] whileFalse:[
-	theLink isNil ifTrue:[^ self subscriptBoundsError:index].
-	theLink := theLink nextLink.
-	runIndex := runIndex + 1.
+        theLink isNil ifTrue:[^ exceptionBlock value].
+        theLink := theLink nextLink.
+        runIndex := runIndex + 1.
     ].
     ^ theLink
 !
@@ -412,5 +422,5 @@
 !LinkedList class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/LinkedList.st,v 1.34 2000-08-22 13:48:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/LinkedList.st,v 1.35 2006-02-15 14:37:34 cg Exp $'
 ! !