fixed a rdonly flag bug in moo_shallowcpy()
added SequenceableCollection>>swap:with:
This commit is contained in:
@ -112,6 +112,8 @@ extend Apex
|
||||
## -------------------------------------------------------
|
||||
method(#dual,#primitive,#lenient) _shallowCopy.
|
||||
method(#dual,#primitive) shallowCopy.
|
||||
method(#dual,#primitive,#lenient) _copy. ## alias to _shallowCopy
|
||||
method(#dual,#primitive) copy. ## alias to shallowCopy
|
||||
|
||||
## -------------------------------------------------------
|
||||
## -------------------------------------------------------
|
||||
|
@ -110,6 +110,17 @@ class SequenceableCollection(Collection)
|
||||
|
||||
startIndex to: stopIndex do: [:i | aBlock value: (self at: i) value: i].
|
||||
}
|
||||
|
||||
method swap: anIndex with: anotherIndex
|
||||
{
|
||||
## the subclass must implement at: and at:put for this to work.
|
||||
|
||||
| tmp |
|
||||
tmp := self at: anIndex.
|
||||
self at: anIndex put: (self at: anotherIndex).
|
||||
self at: anotherIndex put: tmp.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
## -------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user