equal
deleted
inserted
replaced
1110 newCollection := self copyEmptyAndGrow:sz. "must grow, otherwise replace fails" |
1110 newCollection := self copyEmptyAndGrow:sz. "must grow, otherwise replace fails" |
1111 newCollection replaceFrom:1 to:sz with:self startingAt:start. |
1111 newCollection replaceFrom:1 to:sz with:self startingAt:start. |
1112 ^ newCollection |
1112 ^ newCollection |
1113 ! |
1113 ! |
1114 |
1114 |
1115 copyWith:newElement |
|
1116 "return a new collection containing the receivers elements |
|
1117 and the single new element, newElement. |
|
1118 This is different from concatentation, which expects another collection |
|
1119 as argument, but equivalent to copy-and-addLast." |
|
1120 |
|
1121 |newCollection mySize newSize| |
|
1122 |
|
1123 mySize := self size. |
|
1124 newSize := mySize + 1. |
|
1125 newCollection := self copyEmptyAndGrow:newSize. "must grow, otherwise replace fails" |
|
1126 newCollection replaceFrom:1 to:mySize with:self startingAt:1. |
|
1127 newCollection at:newSize put:newElement. |
|
1128 ^newCollection |
|
1129 |
|
1130 " |
|
1131 #(1 2 3 4 5) copyWith:$a |
|
1132 'abcdefg' copyWith:$h |
|
1133 'abcdefg' copyWith:'123' -- will fail: string cannot be stored into string |
|
1134 'abcdefg' copyWith:1 -- will fail: integer cannot be stored into string |
|
1135 " |
|
1136 ! |
|
1137 |
|
1138 postCopy |
1115 postCopy |
1139 "have to copy the contentsArray too" |
1116 "have to copy the contentsArray too" |
1140 |
1117 |
1141 contentsArray := contentsArray shallowCopy |
1118 contentsArray := contentsArray shallowCopy |
1142 ! ! |
1119 ! ! |
1954 ! ! |
1931 ! ! |
1955 |
1932 |
1956 !OrderedCollection class methodsFor:'documentation'! |
1933 !OrderedCollection class methodsFor:'documentation'! |
1957 |
1934 |
1958 version |
1935 version |
1959 ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.100 2012-04-01 11:24:38 cg Exp $' |
1936 ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.101 2012-12-21 11:59:35 cg Exp $' |
1960 ! ! |
1937 ! ! |
|
1938 |