ImmutableArray.st
changeset 371 78ad1d4a0082
parent 364 7a41ced6e4f2
child 382 a1cc92be105d
equal deleted inserted replaced
370:20f04d9b371b 371:78ad1d4a0082
    35 "
    35 "
    36 !
    36 !
    37 
    37 
    38 version
    38 version
    39 "
    39 "
    40 $Header: /cvs/stx/stx/libbasic/ImmutableArray.st,v 1.6 1995-07-23 02:23:34 claus Exp $
    40 $Header: /cvs/stx/stx/libbasic/ImmutableArray.st,v 1.7 1995-08-03 01:25:35 claus Exp $
    41 "
    41 "
    42 !
    42 !
    43 
    43 
    44 documentation
    44 documentation
    45 "
    45 "
   122 ! !
   122 ! !
   123 
   123 
   124 !ImmutableArray methodsFor:'specials'!
   124 !ImmutableArray methodsFor:'specials'!
   125 
   125 
   126 become:anotherObject
   126 become:anotherObject
       
   127     "trigger an error if I should become something else
       
   128      (this would be an even more tricky manipulation)"
       
   129 
   127     self notifyStoreError.
   130     self notifyStoreError.
   128     ^ super become:anotherObject
   131     ^ super become:anotherObject
   129 !
   132 !
   130 
   133 
   131 becomeNil
   134 becomeNil
       
   135     "trigger an error if I should become nil
       
   136      (this would be an even more tricky manipulation)"
       
   137 
   132     self notifyStoreError.
   138     self notifyStoreError.
   133     ^ super becomeNil
   139     ^ super becomeNil
   134 ! !
   140 ! !
   135 
   141 
   136 !ImmutableArray methodsFor:'private'!
   142 !ImmutableArray methodsFor:'private'!
   153 ! !
   159 ! !
   154 
   160 
   155 !ImmutableArray methodsFor:'copying'!
   161 !ImmutableArray methodsFor:'copying'!
   156 
   162 
   157 copyEmptyAndGrow:size
   163 copyEmptyAndGrow:size
       
   164     "when copying, return a real (mutable) Array"
       
   165 
   158     ^ Array new:size
   166     ^ Array new:size
   159 !
   167 !
   160 
   168 
   161 copyEmpty
   169 copyEmpty
       
   170     "when copying, return a real (mutable) Array"
       
   171 
   162     ^ Array new:self size
   172     ^ Array new:self size
   163 !
   173 !
   164 
   174 
   165 shallowCopy
   175 shallowCopy
   166     ^ Array new:self size withAll:self
   176     "when copying, return a real (mutable) Array"
       
   177 
       
   178     |sz|
       
   179 
       
   180     sz := self size.
       
   181     ^ (Array new:sz)
       
   182 	replaceFrom:1 to:sz with:self startingAt:1
   167 !
   183 !
   168 
   184 
   169 postCopy
   185 postCopy
       
   186     "when copied, make it me a real (mutable) Array"
       
   187 
   170     self changeClassTo:Array.
   188     self changeClassTo:Array.
   171 ! !
   189 ! !