#REFACTORING by stefan
class: OrderedCollection
added: #addAll:from:to:beforeIndex:
functionality from List
--- a/OrderedCollection.st Mon Jul 30 09:05:22 2018 +0200
+++ b/OrderedCollection.st Mon Jul 30 11:45:35 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -312,7 +314,6 @@
! !
-
!OrderedCollection methodsFor:'accessing'!
at:anInteger
@@ -649,6 +650,25 @@
"Modified: 15.4.1997 / 12:43:59 / cg"
!
+addAll:aCollection from:startIndex to:endIndex beforeIndex:index
+ "insert elements start to stop from the argument
+ Return the receiver."
+
+ |count idx|
+
+ aCollection isSequenceable ifFalse:[
+ self error:'collection must be sequenceable'
+ ].
+ count := endIndex - startIndex + 1.
+ idx := self makeRoomAtIndex:(index + firstIndex - 1) for:count.
+
+ "/ we are lucky - that thing can count & do bulk copies
+ "/ notice: the above may change firstIndex
+ contentsArray replaceFrom:idx to:(idx + count - 1) with:aCollection startingAt:startIndex.
+
+ "Created: / 30-07-2018 / 11:15:05 / Stefan Vogel"
+!
+
addFirst:anObject
"add the argument, anObject to the beginning of the collection.
Return the argument, anObject."