" Smalltalk/WordArray.st -*- Smalltalk -*- " WordArray : ArrayedCollection () WordArray new: newSize [ | array | array := self _clone. { if (_isIntegerObject(v_newSize)) { struct t_WordArray *array= (struct t_WordArray *)v_array; array->size= v_newSize; array->_elements= (oop)_newBytes(sizeof(int) * _integerValue(v_newSize)); return v_array; } }. ^self primitiveFailed ] WordArray wordAt: index [ { struct t_WordArray *this= (struct t_WordArray *)self; if (_isIntegerObject(v_index) && ((unsigned)v_index < (unsigned)this->size)) return _integerObject(((int *)this->_elements)[_integerValue(v_index)]); }. ^index isInteger ifTrue: [self errorSubscriptBounds: index] ifFalse: [self errorNonIntegerIndex: index]. ] WordArray at: index [ ^self wordAt: index ] WordArray wordAt: index put: anObject [ { struct t_Array *this= (struct t_Array *)self; if (_isIntegerObject(v_index) && ((unsigned)v_index < (unsigned)this->size) && _isIntegerObject(v_anObject)) { ((int *)this->_elements)[_integerValue(v_index)]= _integerValue(v_anObject); return v_anObject; } }. ^(anObject isInteger) ifTrue: [index isInteger ifTrue: [ self errorSubscriptBounds: index] ifFalse: [ self errorNonIntegerIndex: index]] ifFalse: [self errorImproperStore: anObject] ] WordArray at: index put: anObject [ ^self wordAt: index put: anObject ] WordArray printOn: aStream [ self printNameOn: aStream. aStream nextPutAll: '#{'. self do: [:element | aStream print: element; space]. self isEmpty ifFalse: [aStream skip: -1]. aStream nextPut: $} ] " WordArray print [ | first | first := true. '#{' print. self do: [:element | first ifTrue: [first := false] ifFalse: [' ' print]. element print]. '}' print. ] " ImmutableWordArray : WordArray () ImmutableWordArray wordAt: index put: anObject [ ^self errorCannotModify ] ImmutableWordArray at: index put: anObject [ ^self errorCannotModify ] ImmutableWordArray species [ ^WordArray ]