class: LinkedList
authorClaus Gittinger <cg@exept.de>
Mon, 02 Mar 2015 16:14:00 +0100
changeset 17575 11ce80e0ee6b
parent 17574 83bccff028ad
child 17576 2d611305d7e6
class: LinkedList comment/format in:6 methods
LinkedList.st
--- a/LinkedList.st	Mon Mar 02 13:42:47 2015 +0100
+++ b/LinkedList.st	Mon Mar 02 16:14:00 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -143,8 +145,13 @@
     "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 indexed access.
-     Notice, that many methods in SeqColl are based on at:-access,
-     so other inherited methods may be very slow (showing square runtime)."
+     Notice:
+        that many methods in SeqColl are based on at:-access,
+        so other inherited methods may be very slow (showing square runtime).
+        It is a very bad idea to access LinkedList elements by index.
+        many algorithms degenerate to poor performance if you do.
+        This method is provided for protocol completeness,
+        but please consider using another type of collection if you use it"
 
     self obsoleteFeatureWarning:'this will soon change to return the link''s value instead of the link itself'.
 
@@ -155,8 +162,13 @@
     "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 indexed access.
-     Notice, that many methods in SeqColl are based on at:-access,
-     so other inherited methods may be very slow (showing square runtime)."
+     Notice:
+        that many methods in SeqColl are based on at:-access,
+        so other inherited methods may be very slow (showing square runtime).
+        It is a very bad idea to access LinkedList elements by index.
+        many algorithms degenerate to poor performance if you do.
+        This method is provided for protocol completeness,
+        but please consider using another type of collection if you use it"
 
     |theLink
      runIndex "{Class: SmallInteger}"|
@@ -224,8 +236,13 @@
     "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 indexed access.
-     Notice, that many methods in SeqColl are based on at:-access,
-     so other inherited methods may be very slow (showing square runtime)."
+     Notice:
+        that many methods in SeqColl are based on at:-access,
+        so other inherited methods may be very slow (showing square runtime).
+        It is a very bad idea to access LinkedList elements by index.
+        many algorithms degenerate to poor performance if you do.
+        This method is provided for protocol completeness,
+        but please consider using another type of collection if you use it"
 
     ^ self linkAt:index ifAbsent:[ self subscriptBoundsError:index]
 !
@@ -234,8 +251,13 @@
     "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 indexed access.
-     Notice, that many methods in SeqColl are based on at:-access,
-     so other inherited methods may be very slow (showing square runtime)."
+     Notice:
+        that many methods in SeqColl are based on at:-access,
+        so other inherited methods may be very slow (showing square runtime).
+        It is a very bad idea to access LinkedList elements by index.
+        many algorithms degenerate to poor performance if you do.
+        This method is provided for protocol completeness,
+        but please consider using another type of collection if you use it"
 
     |theLink
      runIndex "{Class: SmallInteger}"|
@@ -461,21 +483,27 @@
     "search the collection for aLink, starting the search at index start;
      if found, return the index otherwise return 0. Here, index is defined
      as the link-nodes position in the list.
-     The comparison is done using = (i.e. equality test - not identity test)."
+     The comparison is done using = (i.e. equality test - not identity test).
+     Warning: 
+        it is a very bad idea to access LinkedList elements by index.
+        many algorithms degenerate to poor performance if you do.
+        This method is provided for protocol completeness,
+        but please consider using another type of collection if you use it.
+     "
 
     |theNode idx "{ Class: SmallInteger }"|
 
     theNode := firstLink.
     idx := 1.
     [idx < start] whileTrue:[
-	theNode isNil ifTrue:[^ 0].     "reached the end"
-	theNode := theNode nextLink.
-	idx := idx + 1.
+        theNode isNil ifTrue:[^ 0].     "reached the end"
+        theNode := theNode nextLink.
+        idx := idx + 1.
     ].
     [theNode notNil] whileTrue:[
-	(aLink = theNode) ifTrue:[^ idx].
-	theNode := theNode nextLink.
-	idx := idx + 1.
+        (aLink = theNode) ifTrue:[^ idx].
+        theNode := theNode nextLink.
+        idx := idx + 1.
     ].                                  "reached the end"
     ^ 0
 
@@ -504,7 +532,12 @@
      if found, return the index otherwise return 0. Here, index is defined
      as the link-nodes position in the list.
      The comparison is done using ==
-     (i.e. identity test - not equality test)."
+     (i.e. identity test - not equality test).
+     Notice:
+        It is a very bad idea to access LinkedList elements by index.
+        many algorithms degenerate to poor performance if you do.
+        This method is provided for protocol completeness,
+        but please consider using another type of collection if you use it"
 
     |theNode idx "{ Class: SmallInteger }"|
 
@@ -563,10 +596,10 @@
 !LinkedList class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/LinkedList.st,v 1.50 2015-02-04 16:54:02 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/LinkedList.st,v 1.51 2015-03-02 15:14:00 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/LinkedList.st,v 1.50 2015-02-04 16:54:02 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/LinkedList.st,v 1.51 2015-03-02 15:14:00 cg Exp $'
 ! !