ImmutableByteArray.st
changeset 24173 ee8d63b7e7a4
parent 23923 7f62b7fef163
child 24310 80e6b5fa6041
equal deleted inserted replaced
24172:ddd5ab5bc403 24173:ee8d63b7e7a4
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 2009 by eXept Software AG
     2  COPYRIGHT (c) 2009 by eXept Software AG
     5 	      All Rights Reserved
     3 	      All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
   317     "
   315     "
   318 ! !
   316 ! !
   319 
   317 
   320 !ImmutableByteArray methodsFor:'copying'!
   318 !ImmutableByteArray methodsFor:'copying'!
   321 
   319 
       
   320 shallowCopy
       
   321     "when copying, return a real (mutable) ByteArray"
       
   322 
       
   323     |sz|
       
   324 
       
   325     sz := self size.
       
   326     ^ (ByteArray new:sz) replaceBytesFrom:1 to:sz with:self startingAt:1
       
   327 
       
   328     "
       
   329      #[1 2 3 4] asImmutableByteArray shallowCopy
       
   330     "
       
   331 ! !
       
   332 
       
   333 !ImmutableByteArray methodsFor:'copying-private'!
       
   334 
   322 postCopy
   335 postCopy
   323     "when copied, make me a real (mutable) ByteArray"
   336     "when copied, make me a real (mutable) ByteArray"
   324 
   337 
   325     self changeClassTo:ByteArray.
   338     self changeClassTo:ByteArray.
   326 !
   339 !
   332 
   345 
   333     "
   346     "
   334      #[1 2 3 4] asImmutableByteArray copy          class
   347      #[1 2 3 4] asImmutableByteArray copy          class
   335      #[1 2 3 4] asImmutableByteArray shallowCopy   class
   348      #[1 2 3 4] asImmutableByteArray shallowCopy   class
   336      #[1 2 3 4] asImmutableByteArray deepCopy      class
   349      #[1 2 3 4] asImmutableByteArray deepCopy      class
   337     "
       
   338 !
       
   339 
       
   340 shallowCopy
       
   341     "when copying, return a real (mutable) ByteArray"
       
   342 
       
   343     |sz|
       
   344 
       
   345     sz := self size.
       
   346     ^ (ByteArray new:sz) replaceBytesFrom:1 to:sz with:self startingAt:1
       
   347 
       
   348     "
       
   349      #[1 2 3 4] asImmutableByteArray shallowCopy
       
   350     "
   350     "
   351 ! !
   351 ! !
   352 
   352 
   353 !ImmutableByteArray methodsFor:'printing & storing'!
   353 !ImmutableByteArray methodsFor:'printing & storing'!
   354 
   354