equal
deleted
inserted
replaced
275 Kludges around the stupid definition of OrderedCollection>>new:" |
275 Kludges around the stupid definition of OrderedCollection>>new:" |
276 |
276 |
277 ^ self newWithSize:n |
277 ^ self newWithSize:n |
278 ! ! |
278 ! ! |
279 |
279 |
|
280 |
280 !Collection class methodsFor:'Signal constants'! |
281 !Collection class methodsFor:'Signal constants'! |
281 |
282 |
282 emptyCollectionSignal |
283 emptyCollectionSignal |
283 "return the signal used to report non-allowed operation on empty collections" |
284 "return the signal used to report non-allowed operation on empty collections" |
284 |
285 |
316 " |
317 " |
317 |
318 |
318 "Created: / 09-01-2011 / 10:37:15 / cg" |
319 "Created: / 09-01-2011 / 10:37:15 / cg" |
319 ! ! |
320 ! ! |
320 |
321 |
321 !Collection class methodsFor:'misc ui support'! |
|
322 |
|
323 iconInBrowserSymbol |
|
324 <resource: #programImage> |
|
325 |
|
326 ^ #containerClassBrowserIcon |
|
327 ! ! |
|
328 |
322 |
329 !Collection class methodsFor:'queries'! |
323 !Collection class methodsFor:'queries'! |
330 |
324 |
331 growIsCheap |
325 growIsCheap |
332 "return true, if this collection can easily grow |
326 "return true, if this collection can easily grow |
532 ^ self intersect:aCollection |
526 ^ self intersect:aCollection |
533 |
527 |
534 "Created: / 22-10-2008 / 21:29:27 / cg" |
528 "Created: / 22-10-2008 / 21:29:27 / cg" |
535 ! ! |
529 ! ! |
536 |
530 |
|
531 |
537 !Collection methodsFor:'accessing'! |
532 !Collection methodsFor:'accessing'! |
538 |
533 |
539 anElement |
534 anElement |
540 "return any element from the collection, |
535 "return any element from the collection, |
541 report an error if there is none. |
536 report an error if there is none. |
638 ^ self emptyCollectionError |
633 ^ self emptyCollectionError |
639 ! |
634 ! |
640 |
635 |
641 first:n |
636 first:n |
642 "return the n first elements of the collection. |
637 "return the n first elements of the collection. |
643 Raises an error if there are not enough elements in the receiver. |
638 No longer raises an error if there are not enough elements; |
|
639 instead, returns what is there. |
|
640 |
644 For unordered collections, this simply returns the first |
641 For unordered collections, this simply returns the first |
645 n elements when enumerating them |
642 n elements when enumerating them. |
646 (Warning: the contents of the returned collection is not deterministic in this case). |
643 (Warning: the contents of the returned collection is not deterministic in this case). |
647 This should be redefined in subclasses." |
644 This should be redefined in subclasses." |
648 |
645 |
649 |coll remain| |
646 |coll remain| |
650 |
647 |
657 remain := remain - 1. |
654 remain := remain - 1. |
658 remain == 0 ifTrue:[ |
655 remain == 0 ifTrue:[ |
659 ^ coll |
656 ^ coll |
660 ]. |
657 ]. |
661 ]. |
658 ]. |
662 |
659 "/ OLD: |
663 "error if collection has not enough elements" |
660 "/ "error if collection has not enough elements" |
664 ^ self notEnoughElementsError |
661 "/ ^ self notEnoughElementsError |
|
662 "/ NEW: |
|
663 "/ return what we have - no error if not enough elements |
|
664 ^ coll. |
665 |
665 |
666 " |
666 " |
667 #(1 2 3 4 5) first:3 |
667 #(1 2 3 4 5) first:3 |
668 #(1 2 3 4 5) asSet first:3 |
668 #(1 2 3 4 5) asSet first:3 |
|
669 #(1 2 3) first:5 |
|
670 #(1 2 3) asSet first:5 |
669 " |
671 " |
670 |
672 |
671 "Modified (format): / 29-09-2011 / 10:16:49 / cg" |
673 "Modified (format): / 29-09-2011 / 10:16:49 / cg" |
672 ! |
674 ! |
673 |
675 |
5735 "dispatch for visitor pattern; send #visitCollection:with: to aVisitor" |
5737 "dispatch for visitor pattern; send #visitCollection:with: to aVisitor" |
5736 |
5738 |
5737 ^ aVisitor visitCollection:self with:aParameter |
5739 ^ aVisitor visitCollection:self with:aParameter |
5738 ! ! |
5740 ! ! |
5739 |
5741 |
|
5742 |
5740 !Collection class methodsFor:'documentation'! |
5743 !Collection class methodsFor:'documentation'! |
5741 |
5744 |
5742 version |
5745 version |
5743 ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.359 2015-03-02 12:12:24 cg Exp $' |
5746 ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.360 2015-03-28 08:55:33 cg Exp $' |
5744 ! |
5747 ! |
5745 |
5748 |
5746 version_CVS |
5749 version_CVS |
5747 ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.359 2015-03-02 12:12:24 cg Exp $' |
5750 ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.360 2015-03-28 08:55:33 cg Exp $' |
5748 ! ! |
5751 ! ! |
5749 |
5752 |
5750 |
5753 |
5751 Collection initialize! |
5754 Collection initialize! |