693 (OrderedCollection withAll:#(1 2 3 4 5)) removeFirst; yourself |
694 (OrderedCollection withAll:#(1 2 3 4 5)) removeFirst; yourself |
694 OrderedCollection new removeFirst |
695 OrderedCollection new removeFirst |
695 (SortedCollection withAll:#(5 4 3 2 1)) removeFirst; yourself |
696 (SortedCollection withAll:#(5 4 3 2 1)) removeFirst; yourself |
696 " |
697 " |
697 |
698 |
698 "Modified: / 12.11.1997 / 17:58:43 / cg" |
699 "Modified: / 30.7.1998 / 13:19:59 / cg" |
699 ! |
700 ! |
700 |
701 |
701 removeFirst:n |
702 removeFirst:n |
702 "remove the first n elements from the collection; |
703 "remove the first n elements from the collection; |
703 Return a collection containing the removed elements." |
704 Return a collection containing the removed elements." |
734 (OrderedCollection withAll:#(1 2 3 4 5)) removeFirst:6 |
735 (OrderedCollection withAll:#(1 2 3 4 5)) removeFirst:6 |
735 (SortedCollection withAll:#(5 4 3 2 1)) removeFirst:2; yourself |
736 (SortedCollection withAll:#(5 4 3 2 1)) removeFirst:2; yourself |
736 " |
737 " |
737 |
738 |
738 "Modified: 8.2.1997 / 19:20:18 / cg" |
739 "Modified: 8.2.1997 / 19:20:18 / cg" |
|
740 ! |
|
741 |
|
742 removeFirstIfAbsent:exceptionBlock |
|
743 "remove the first element from the collection; return the element. |
|
744 If there is no element in the receiver collection, return the value from |
|
745 exceptionBlock." |
|
746 |
|
747 |anObject fI "{ Class: SmallInteger }" | |
|
748 |
|
749 fI := firstIndex. |
|
750 |
|
751 fI > lastIndex ifTrue:[ |
|
752 "error if collection is empty" |
|
753 ^ exceptionBlock value. |
|
754 ]. |
|
755 |
|
756 anObject := contentsArray basicAt:fI. |
|
757 |
|
758 "/ nil it out, to allow GC to reclaim it. |
|
759 contentsArray basicAt:fI put:nil. |
|
760 |
|
761 fI := fI + 1. |
|
762 |
|
763 fI > lastIndex ifTrue:[ |
|
764 "reset to avoid ever growing" |
|
765 fI := 1. |
|
766 lastIndex := 0 |
|
767 ]. |
|
768 firstIndex := fI. |
|
769 ^ anObject |
|
770 |
|
771 " |
|
772 (OrderedCollection withAll:#(1 2 3 4 5)) removeFirst; yourself |
|
773 OrderedCollection new removeFirst |
|
774 (SortedCollection withAll:#(5 4 3 2 1)) removeFirst; yourself |
|
775 " |
|
776 |
|
777 "Modified: / 12.11.1997 / 17:58:43 / cg" |
|
778 "Created: / 30.7.1998 / 13:19:42 / cg" |
739 ! |
779 ! |
740 |
780 |
741 removeFrom:startIndex to:stopIndex |
781 removeFrom:startIndex to:stopIndex |
742 "added for ST-80 compatibility. |
782 "added for ST-80 compatibility. |
743 Same as removeFromIndex:toIndex:." |
783 Same as removeFromIndex:toIndex:." |