SeqColl.st
changeset 348 5ac1b6b43600
parent 308 f04744ef7b5d
child 356 6c5ce0e1e7a8
equal deleted inserted replaced
347:0d4c08ca9da3 348:5ac1b6b43600
    19 
    19 
    20 SequenceableCollection comment:'
    20 SequenceableCollection comment:'
    21 COPYRIGHT (c) 1989 by Claus Gittinger
    21 COPYRIGHT (c) 1989 by Claus Gittinger
    22 	      All Rights Reserved
    22 	      All Rights Reserved
    23 
    23 
    24 $Header: /cvs/stx/stx/libbasic/Attic/SeqColl.st,v 1.27 1995-03-18 05:06:08 claus Exp $
    24 $Header: /cvs/stx/stx/libbasic/Attic/SeqColl.st,v 1.28 1995-05-18 15:10:08 claus Exp $
    25 '!
    25 '!
    26 
    26 
    27 !SequenceableCollection class methodsFor:'documentation'!
    27 !SequenceableCollection class methodsFor:'documentation'!
    28 
    28 
    29 copyright
    29 copyright
    40 "
    40 "
    41 !
    41 !
    42 
    42 
    43 version
    43 version
    44 "
    44 "
    45 $Header: /cvs/stx/stx/libbasic/Attic/SeqColl.st,v 1.27 1995-03-18 05:06:08 claus Exp $
    45 $Header: /cvs/stx/stx/libbasic/Attic/SeqColl.st,v 1.28 1995-05-18 15:10:08 claus Exp $
    46 "
    46 "
    47 !
    47 !
    48 
    48 
    49 documentation
    49 documentation
    50 "
    50 "
  1071     "
  1071     "
  1072 !
  1072 !
  1073 
  1073 
  1074 removeFromIndex:startIndex toIndex:endIndex
  1074 removeFromIndex:startIndex toIndex:endIndex
  1075     "remove the elements stored at indexes between startIndex and endIndex.
  1075     "remove the elements stored at indexes between startIndex and endIndex.
       
  1076      Return the receiver.
       
  1077      Returning the receiver is a historic leftover - it may at one
       
  1078      time return a collection of the removed elements.
  1076 
  1079 
  1077      Notice, that this is modifies the receiver - NOT a copy; 
  1080      Notice, that this is modifies the receiver - NOT a copy; 
  1078      therefore any other users of the receiver will also see this change.
  1081      therefore any other users of the receiver will also see this change.
  1079      Also note, that it may be a slow operation for some collections,
  1082      Also note, that it may be a slow operation for some collections,
  1080      due to the grow:-message, which is inefficient for fixed size 
  1083      due to the grow:-message, which is inefficient for fixed size 
  1106      #(1 2 3 4 5 6 7 8 9 0) asOrderedCollection removeFromIndex:1 toIndex:10 
  1109      #(1 2 3 4 5 6 7 8 9 0) asOrderedCollection removeFromIndex:1 toIndex:10 
  1107      #(1 2 3 4 5 6 7 8 9 0) removeFromIndex:1 toIndex:10 
  1110      #(1 2 3 4 5 6 7 8 9 0) removeFromIndex:1 toIndex:10 
  1108     "
  1111     "
  1109 !
  1112 !
  1110 
  1113 
  1111 removeAtIndex:index
  1114 removeAtIndex:anIndex
  1112     "remove the argument stored at index and return it.
  1115     "remove the element stored at anIndex. Return the removed object.
  1113 
  1116 
  1114      Notice, that this is modifies the receiver NOT a copy.
  1117      Notice, that this is modifies the receiver NOT a copy.
  1115      Also note, that it may be a slow operation for some collections,
  1118      Also note, that it may be a slow operation for some collections,
  1116      due to the grow:-message, which is inefficient for fixed size 
  1119      due to the grow:-message, which is inefficient for fixed size 
  1117      collections (i.e. for Strings and Arrays it is not recommened)."
  1120      collections (i.e. for Strings and Arrays it is not recommened)."
  1118 
  1121 
  1119     |element|
  1122     |element|
  1120 
  1123 
  1121     element := self at:index.
  1124     element := self at:anIndex.
  1122     self removeIndex:index.
  1125     self removeFromIndex:anIndex toIndex:anIndex.
  1123     ^ element
  1126     ^ element
  1124 
  1127 
  1125     "
  1128     "
       
  1129      #(1 2 3 4 5 6 7 8 9) asOrderedCollection removeAtIndex:3
       
  1130      #(1 2 3 4 5) asOrderedCollection removeAtIndex:6
  1126      #($a $b $c $d $e $f $g) removeAtIndex:3
  1131      #($a $b $c $d $e $f $g) removeAtIndex:3
  1127     "
  1132     "
  1128 !
  1133 !
  1129 
  1134 
  1130 removeIndex:index
  1135 removeIndex:index
  1136      collections (i.e. for Strings and Arrays it is not recommened)."
  1141      collections (i.e. for Strings and Arrays it is not recommened)."
  1137 
  1142 
  1138     self removeFromIndex:index toIndex:index
  1143     self removeFromIndex:index toIndex:index
  1139 
  1144 
  1140     "
  1145     "
       
  1146      #(1 2 3 4 5 6 7 8 9) asOrderedCollection removeIndex:3
       
  1147      #(1 2 3 4 5) asOrderedCollection removeIndex:6
  1141      #($a $b $c $d $e $f $g) removeIndex:3
  1148      #($a $b $c $d $e $f $g) removeIndex:3
  1142     "
  1149     "
  1143 !
  1150 !
  1144 
  1151 
  1145 removeFirst
  1152 removeFirst
  1151      collections (i.e. for Strings and Arrays it is not recommened)."
  1158      collections (i.e. for Strings and Arrays it is not recommened)."
  1152 
  1159 
  1153     ^ self removeAtIndex:1
  1160     ^ self removeAtIndex:1
  1154 
  1161 
  1155     "
  1162     "
  1156     |a|
  1163      |a|
  1157      a := #(1 2 3 4 5 6).
  1164      a := #(1 2 3 4 5 6).
  1158      a removeFirst.
  1165      a removeFirst.
  1159      a
  1166      a 
  1160     "
  1167     "
  1161 !
  1168 !
  1162 
  1169 
  1163 removeLast
  1170 removeLast
  1164     "remove the last element of the receiver and return it.
  1171     "remove the last element of the receiver and return it.
  1169      collections (i.e. for Strings and Arrays it is not recommened)."
  1176      collections (i.e. for Strings and Arrays it is not recommened)."
  1170 
  1177 
  1171     ^ self removeAtIndex:(self size) 
  1178     ^ self removeAtIndex:(self size) 
  1172 
  1179 
  1173     "
  1180     "
  1174     |a|
  1181      |a|
  1175      a := #(1 2 3 4 5 6).
  1182      a := #(1 2 3 4 5 6).
  1176      a removeLast.
  1183      a removeLast.
  1177      a   
  1184      a   
  1178     "
  1185     "
  1179 ! !
  1186 ! !