fixed a rdonly flag bug in moo_shallowcpy()

added SequenceableCollection>>swap:with:
This commit is contained in:
hyunghwan.chung
2019-06-19 09:21:28 +00:00
parent e036f3f6d7
commit 6b2cb6f9df
5 changed files with 16 additions and 1 deletions

View File

@ -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
## -------------------------------------------------------
## -------------------------------------------------------

View File

@ -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.
}
}
## -------------------------------------------------------------------------------