SequenceableCollection.st
changeset 22599 c7f2feb3e7d7
parent 22565 4dab1e4522a8
child 22715 c938e3910594
--- a/SequenceableCollection.st	Wed Mar 07 17:32:25 2018 +0100
+++ b/SequenceableCollection.st	Wed Mar 07 17:50:20 2018 +0100
@@ -451,6 +451,7 @@
 ! !
 
 
+
 !SequenceableCollection methodsFor:'Compatibility-Squeak'!
 
 allButFirst
@@ -691,6 +692,24 @@
     self clearContents
 !
 
+forceTo:newSize paddingWith:padding
+    self size > newSize ifTrue:[
+        ^ self copyTo:newSize
+    ].
+    self size < newSize ifTrue:[
+        ^ (self species new:newSize) 
+            atAllPut:padding;
+            replaceFrom:1 with:self startingAt:1;
+            yourself.
+    ].
+    ^ self.
+
+    "
+     #[1 2 3 4] forceTo:10 paddingWith:255
+     #[1 2 3 4] forceTo:3 paddingWith:255
+    "
+!
+
 joinWith:separatingElement
     "return a collection generated by concatenating my elements
      and embedding separatingElement in between.
@@ -769,6 +788,7 @@
     ^ self replaceFrom:start to:stop with:anArray startingAt:repStart
 ! !
 
+
 !SequenceableCollection methodsFor:'accessing'!
 
 after:anObject