equal
deleted
inserted
replaced
19 |
19 |
20 VariableArray comment:' |
20 VariableArray 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/libbasic2/VariableArray.st,v 1.8 1994-10-10 00:52:54 claus Exp $ |
24 $Header: /cvs/stx/stx/libbasic2/VariableArray.st,v 1.9 1995-02-15 10:29:29 claus Exp $ |
25 '! |
25 '! |
26 |
26 |
27 !VariableArray class methodsFor:'documentation'! |
27 !VariableArray 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/libbasic2/VariableArray.st,v 1.8 1994-10-10 00:52:54 claus Exp $ |
45 $Header: /cvs/stx/stx/libbasic2/VariableArray.st,v 1.9 1995-02-15 10:29:29 claus Exp $ |
46 " |
46 " |
47 ! |
47 ! |
48 |
48 |
49 documentation |
49 documentation |
50 " |
50 " |
51 VariableArrays can grow and shrink - in contrast to Arrays which are |
51 VariableArrays can grow and shrink - in contrast to Arrays which are |
52 fixed in size. |
52 fixed in size. |
53 WARNING: Do not use this class for new applications - its a historic |
53 WARNING: Do not use this class for new applications - its a historic |
54 leftover from times when no OrderedCollection existed. |
54 leftover from times when no OrderedCollection existed. |
55 |
55 |
56 Use OrderedCollection, which offers more functionality, and is even |
56 Use OrderedCollection, which offers more functionality, and is even |
57 a bit faster in some operations. |
57 a bit faster in some operations. |
58 " |
58 " |
59 ! ! |
59 ! ! |
236 grow:newSize |
236 grow:newSize |
237 "grow to newSize" |
237 "grow to newSize" |
238 |
238 |
239 |newArray| |
239 |newArray| |
240 |
240 |
|
241 (newSize == tally) ifTrue:[^ self]. |
|
242 |
241 (newSize > tally) ifTrue:[ |
243 (newSize > tally) ifTrue:[ |
242 (newSize > contentsArray size) ifTrue:[ |
244 (newSize > contentsArray size) ifTrue:[ |
243 newArray := Array new:(newSize * 2). |
245 newArray := Array new:(newSize * 2). |
244 newArray replaceFrom:1 to:tally with:contentsArray startingAt:1. |
246 newArray replaceFrom:1 to:tally with:contentsArray startingAt:1. |
245 contentsArray := newArray |
247 contentsArray := newArray |