#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Wed, 13 Feb 2019 18:03:53 +0100
changeset 23728 8a0345aa717e
parent 23727 be95133fcd36
child 23729 772ddbedfb9d
#FEATURE by cg class: OrderedDictionary added: #copyFrom: #copyTo: #copyValuesFrom: #copyValuesFrom:to: #copyValuesTo: comment/format in: #copyFrom:to: #copyWithout:
OrderedDictionary.st
--- a/OrderedDictionary.st	Wed Feb 13 17:59:07 2019 +0100
+++ b/OrderedDictionary.st	Wed Feb 13 18:03:53 2019 +0100
@@ -613,8 +613,17 @@
     ^ self species new: 10
 !
 
+copyFrom:startIndex 
+    "Return a copy of the receiver that contains associations from 
+     position startIndex to the end."
+    
+    ^ self copyFrom:startIndex to:self size
+
+    "Created: / 13-02-2019 / 17:59:58 / Claus Gittinger"
+!
+
 copyFrom:startIndex to:endIndex 
-    "Return a copy of the receiver that contains elements from 
+    "Return a copy of the receiver that contains associations from 
      position startIndex to endIndex."
     
     |newDict|
@@ -630,9 +639,59 @@
         newDict add:(self associationAt:(order at:index))
     ].
     ^ newDict
+
+    "Modified (comment): / 13-02-2019 / 18:01:03 / Claus Gittinger"
+!
+
+copyTo:endIndex 
+    "Return a copy of the receiver that contains associations from 
+     the start to endIndex."
+    
+    ^ self copyFrom:1 to:endIndex
+
+    "Created: / 13-02-2019 / 18:00:24 / Claus Gittinger"
+!
+
+copyValuesFrom:startIndex 
+    "Return a copy of the receiver that contains values from 
+     position startIndex to the end."
+    
+    ^ self copyValuesFrom:startIndex to:self size
+
+    "Created: / 13-02-2019 / 18:01:24 / Claus Gittinger"
 !
 
-copyWithout: anAssociation 
+copyValuesFrom:startIndex to:endIndex 
+    "Return a copy of the receiver that contains values from 
+     position startIndex to endIndex."
+    
+    |outColl|
+
+    endIndex < startIndex ifTrue:[
+        ^ self copyEmpty
+    ].
+    (startIndex < 1 or:[ endIndex > order size ]) ifTrue:[
+        ^ self errorNotFound
+    ].
+    outColl := OrderedCollection new:(endIndex - startIndex + 1).
+    startIndex to:endIndex do:[:index | 
+        outColl add:(self at:(order at:index))
+    ].
+    ^ outColl
+
+    "Created: / 13-02-2019 / 18:03:19 / Claus Gittinger"
+!
+
+copyValuesTo:endIndex 
+    "Return a copy of the receiver that contains values from 
+     the start to endIndex."
+    
+    ^ self copyValuesFrom:1 to:endIndex
+
+    "Created: / 13-02-2019 / 18:02:13 / Claus Gittinger"
+!
+
+copyWithout:anAssociation 
     "Return a copy of the dictionary that is 1 smaller than the receiver and 
      does not include the argument, anAssociation
      No error is reported, if elementToSkip is not in the collection."
@@ -664,6 +723,8 @@
      d2 := d copyWithout:(4->'4').
      d2      
     "
+
+    "Modified (format): / 13-02-2019 / 18:01:10 / Claus Gittinger"
 !
 
 postCopy