ArrColl.st
changeset 28 4606b818d646
parent 27 d98f9dd437f7
child 68 59faa75185ba
equal deleted inserted replaced
27:d98f9dd437f7 28:4606b818d646
    22 COPYRIGHT (c) 1989 by Claus Gittinger
    22 COPYRIGHT (c) 1989 by Claus Gittinger
    23              All Rights Reserved
    23              All Rights Reserved
    24 
    24 
    25 ArrayedCollections are collections where the elements can be accessed via an integer index.
    25 ArrayedCollections are collections where the elements can be accessed via an integer index.
    26 
    26 
    27 $Header: /cvs/stx/stx/libbasic/Attic/ArrColl.st,v 1.5 1993-12-20 17:32:15 claus Exp $
    27 $Header: /cvs/stx/stx/libbasic/Attic/ArrColl.st,v 1.6 1994-01-08 16:08:00 claus Exp $
    28 written spring 89 by claus
    28 written spring 89 by claus
    29 '!
    29 '!
    30 
    30 
    31 !ArrayedCollection class methodsFor:'instance creation'!
    31 !ArrayedCollection class methodsFor:'instance creation'!
    32 
    32 
   111         ]
   111         ]
   112     ].
   112     ].
   113     ^ newCollection
   113     ^ newCollection
   114 ! !
   114 ! !
   115 
   115 
       
   116 !ArrayedCollection methodsFor:'accessing'!
       
   117 
       
   118 at:index ifAbsent:exceptionBlock
       
   119     "return the element at index, if the index is invalid,
       
   120      return the value of evaluating the exceptionBlock."
       
   121 
       
   122     (index < 1 or:[index > self size]) ifTrue:[
       
   123         ^ exceptionBlock value
       
   124     ].
       
   125     ^ self at:index
       
   126 
       
   127     "#(1 2 3) at:4 ifAbsent:['no such index']"
       
   128 ! !
       
   129 
   116 !ArrayedCollection methodsFor:'testing'!
   130 !ArrayedCollection methodsFor:'testing'!
   117 
   131 
   118 size
   132 size
   119     "redefined to re-enable size->basicSize forwarding
   133     "redefined to re-enable size->basicSize forwarding
   120      (it is cought in SequencableCollection)"
   134      (it is cought in SequencableCollection)"