equal
deleted
inserted
replaced
670 Returning the receiver here is a historic leftover - it may change. |
670 Returning the receiver here is a historic leftover - it may change. |
671 Please use yourself in a cascade, if you need the receivers value |
671 Please use yourself in a cascade, if you need the receivers value |
672 when using this method." |
672 when using this method." |
673 |
673 |
674 |nDeleted "{ Class: SmallInteger }" |
674 |nDeleted "{ Class: SmallInteger }" |
675 newLastIndex| |
675 newLastIndex sz| |
676 |
676 |
677 (startIndex < 1 |
677 sz := self size. |
678 or:[stopIndex > self size]) ifTrue:[ |
678 |
|
679 (startIndex < 1 or:[stopIndex > sz]) ifTrue:[ |
679 ^ self notEnoughElementsError |
680 ^ self notEnoughElementsError |
680 ]. |
681 ]. |
681 |
682 |
682 nDeleted := stopIndex - startIndex + 1. |
683 nDeleted := stopIndex - startIndex + 1. |
683 nDeleted < 0 ifTrue:[ |
684 nDeleted < 0 ifTrue:[ |
687 nDeleted == 0 ifTrue:[^ self]. |
688 nDeleted == 0 ifTrue:[^ self]. |
688 |
689 |
689 "/ |
690 "/ |
690 "/ can be done faster, when removing the first elements |
691 "/ can be done faster, when removing the first elements |
691 "/ |
692 "/ |
692 startIndex == firstIndex ifTrue:[ |
693 startIndex == 1 ifTrue:[ |
693 "/ nil out (helps GC) |
694 "/ nil out (helps GC) |
694 contentsArray |
695 contentsArray |
695 from:firstIndex |
696 from:firstIndex |
696 to:firstIndex + nDeleted - 1 |
697 to:firstIndex + nDeleted - 1 |
697 put:nil. |
698 put:nil. |
698 firstIndex := firstIndex + nDeleted |
699 firstIndex := firstIndex + nDeleted |
699 ] ifFalse:[ |
700 ] ifFalse:[ |
700 "/ |
701 "/ |
701 "/ can be done faster, when removing the last elements |
702 "/ can be done faster, when removing the last elements |
702 "/ |
703 "/ |
703 stopIndex == lastIndex ifTrue:[ |
704 stopIndex == sz ifTrue:[ |
704 "/ nil out (helps GC) |
705 "/ nil out (helps GC) |
705 contentsArray |
706 contentsArray |
706 from:lastIndex - nDeleted + 1 |
707 from:lastIndex - nDeleted + 1 |
707 to:lastIndex |
708 to:lastIndex |
708 put:nil. |
709 put:nil. |
744 #(1 2 3 4 5 6 7 8 9) asOrderedCollection removeFromIndex:1 toIndex:3 |
745 #(1 2 3 4 5 6 7 8 9) asOrderedCollection removeFromIndex:1 toIndex:3 |
745 #(1 2 3 4 5 6 7 8 9) asOrderedCollection removeFromIndex:6 toIndex:9 |
746 #(1 2 3 4 5 6 7 8 9) asOrderedCollection removeFromIndex:6 toIndex:9 |
746 #(1 2 3 4 5) asOrderedCollection removeFromIndex:3 toIndex:6 |
747 #(1 2 3 4 5) asOrderedCollection removeFromIndex:3 toIndex:6 |
747 " |
748 " |
748 |
749 |
749 "Modified: 8.2.1997 / 19:21:32 / cg" |
750 "Modified: 8.2.1997 / 19:31:05 / cg" |
750 ! |
751 ! |
751 |
752 |
752 removeIdentical:anObject ifAbsent:exceptionBlock |
753 removeIdentical:anObject ifAbsent:exceptionBlock |
753 "remove the first element which is identical to anObject; |
754 "remove the first element which is identical to anObject; |
754 if found, remove and return it; |
755 if found, remove and return it; |
1629 ! ! |
1630 ! ! |
1630 |
1631 |
1631 !OrderedCollection class methodsFor:'documentation'! |
1632 !OrderedCollection class methodsFor:'documentation'! |
1632 |
1633 |
1633 version |
1634 version |
1634 ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.60 1997-02-08 18:22:27 cg Exp $' |
1635 ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.61 1997-02-08 18:31:43 cg Exp $' |
1635 ! ! |
1636 ! ! |