OrdColl.st
changeset 375 e5019c22f40e
parent 370 20f04d9b371b
child 379 5b5a130ccd09
equal deleted inserted replaced
374:7eb5bedfaa1c 375:e5019c22f40e
    19 
    19 
    20 OrderedCollection comment:'
    20 OrderedCollection comment:'
    21 COPYRIGHT (c) 1989 by Claus Gittinger
    21 COPYRIGHT (c) 1989 by Claus Gittinger
    22 	      All Rights Reserved
    22 	      All Rights Reserved
    23 
    23 
    24 $Header: /cvs/stx/stx/libbasic/Attic/OrdColl.st,v 1.28 1995-08-03 01:16:13 claus Exp $
    24 $Header: /cvs/stx/stx/libbasic/Attic/OrdColl.st,v 1.29 1995-08-08 00:48:10 claus Exp $
    25 '!
    25 '!
    26 
    26 
    27 !OrderedCollection class methodsFor:'documentation'!
    27 !OrderedCollection class methodsFor:'documentation'!
    28 
    28 
    29 copyright
    29 copyright
    40 "
    40 "
    41 !
    41 !
    42 
    42 
    43 version
    43 version
    44 "
    44 "
    45 $Header: /cvs/stx/stx/libbasic/Attic/OrdColl.st,v 1.28 1995-08-03 01:16:13 claus Exp $
    45 $Header: /cvs/stx/stx/libbasic/Attic/OrdColl.st,v 1.29 1995-08-08 00:48:10 claus Exp $
    46 "
    46 "
    47 !
    47 !
    48 
    48 
    49 documentation
    49 documentation
    50 "
    50 "
   586 		lastIndex := newLast.
   586 		lastIndex := newLast.
   587 		^ self
   587 		^ self
   588 	    ].
   588 	    ].
   589 
   589 
   590 	    newContents := Array basicNew:newSize.
   590 	    newContents := Array basicNew:newSize.
   591 	    newContents replaceFrom:1 to:(lastIndex - firstIndex + 1) with:contentsArray.
   591 	    newContents replaceFrom:1 to:oldSize with:contentsArray startingAt:firstIndex.
   592 	    contentsArray := newContents.
   592 	    contentsArray := newContents.
   593 	    firstIndex := 1.
   593 	    firstIndex := 1.
   594 	    lastIndex := newSize
   594 	    lastIndex := newSize
   595 	]
   595 	]
   596     ]
   596     ]
   794      shift instead of growing. This helps collections which get
   794      shift instead of growing. This helps collections which get
   795      elements removed at front and added at the end.
   795      elements removed at front and added at the end.
   796     "
   796     "
   797     oldSize > (sz * 2) ifTrue:[
   797     oldSize > (sz * 2) ifTrue:[
   798 	startIndex := firstIndex // 4.
   798 	startIndex := firstIndex // 4.
       
   799 	startIndex == 0 ifTrue:[
       
   800 	    startIndex := 1
       
   801 	].
   799 	contentsArray 
   802 	contentsArray 
   800 	    replaceFrom:startIndex
   803 	    replaceFrom:startIndex
   801 	    to:startIndex + sz - 1
   804 	    to:startIndex + sz - 1
   802 	    with:contentsArray
   805 	    with:contentsArray
   803 	    startingAt:firstIndex.
   806 	    startingAt:firstIndex.
   843      shift instead of growing. This helps collections
   846      shift instead of growing. This helps collections
   844      which get elements removed at the end and added at front.
   847      which get elements removed at the end and added at front.
   845     "
   848     "
   846     oldSize > (sz * 2) ifTrue:[
   849     oldSize > (sz * 2) ifTrue:[
   847 	startIndex := oldSize // 4.
   850 	startIndex := oldSize // 4.
       
   851 	startIndex == 0 ifTrue:[
       
   852 	    startIndex := 1
       
   853 	].
   848 	contentsArray
   854 	contentsArray
   849 	    replaceFrom:startIndex
   855 	    replaceFrom:startIndex
   850 	    to:startIndex + sz - 1
   856 	    to:startIndex + sz - 1
   851 	    with:contentsArray
   857 	    with:contentsArray
   852 	    startingAt:1.
   858 	    startingAt:1.