Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.824.mcz ==================== Summary ==================== Name: Collections-nice.824 Author: nice Time: 7 April 2019, 10:40:26.559826 pm UUID: e6d75dba-26a8-4945-a930-3d79f8cd4969 Ancestors: Collections-ul.823 Implement Collection>>#log2, since it already responds to #ln and #log... Correct a Pharoism in DefaultSortFunction comment, there is no #threeWayCompareTo: because we prefer the space-ship operator <=> Correct a slip in LazyCharacterSet comment. Let ({1. 3/2. 2} as: Interval) work as it should. Remove Interval>>#remove: since it duplicates unecessarily super remove:ifAbsent: (which shouldNotImplement already). Don't spend too much time sorting an Interval, it's already sorted. =============== Diff against Collections-ul.823 =============== Item was added: + ----- Method: Collection>>log2 (in category 'math functions') ----- + log2 + ^ self collect: [:each | each log2]! Item was changed: SortFunction subclass: #DefaultSortFunction instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Collections-SortFunctions'! + !DefaultSortFunction commentStamp: 'nice 4/6/2019 15:08' prior: 0! + A DefaultSortFunction is a collator using the default three way compare <=> operator. - !DefaultSortFunction commentStamp: 'nice 11/7/2017 23:43' prior: 0! - A DefaultSortFunction is a collator using the default <=> operator. It is known to work on String and Magnitude. It is generally not usefull to create a new instance, and the recommended pattern is to use the single instance available by sending the message SortFunction default . + For other objects that don't understand <=> it is necessary to use a custom SortFunction rather than the default one. - For other objects that don't understand threeWayCompareTo: it is necessary to use a custom SortFunction rather than the default one. ! Item was changed: ----- Method: Interval class>>newFrom: (in category 'instance creation') ----- newFrom: aCollection "Answer an instance of me containing the same elements as aCollection." | newInterval n | - (n := aCollection size) <= 1 ifTrue: [ n = 0 ifTrue: [^self from: 1 to: 0]. + ^self from: aCollection anyOne to: aCollection anyOne]. + newInterval := self + from: aCollection first + to: aCollection last + by: (aCollection last - aCollection first) / (n - 1). + (newInterval hasEqualElements: aCollection) + ifFalse: + [self error: 'The argument is not an arithmetic progression']. - ^self from: aCollection first to: aCollection last]. - newInterval := self from: aCollection first to: aCollection last - by: (aCollection last - aCollection first) // (n - 1). - aCollection ~= newInterval - ifTrue: [ - "Give a second chance, because progression might be arithmetic, but = answer false" - (newInterval hasEqualElements: aCollection) ifFalse: [ - self error: 'The argument is not an arithmetic progression']]. ^newInterval " Interval newFrom: {1. 2. 3} {33. 5. -23} as: Interval {33. 5. -22} as: Interval (an error) (-4 to: -12 by: -1) as: Interval #(2 4 6) asByteArray as: Interval. "! Item was removed: - ----- Method: Interval>>remove: (in category 'removing') ----- - remove: newObject - "Removing from an Interval is not allowed." - - self error: 'elements cannot be removed from an Interval'! Item was added: + ----- Method: Interval>>sorted (in category 'sorting') ----- + sorted + "an Interval is already sorted" + step < 0 ifTrue: [^self reversed]. + ^self! Item was changed: CharacterSet subclass: #LazyCharacterSet instanceVariableNames: 'block' classVariableNames: '' poolDictionaries: '' category: 'Collections-Support'! + !LazyCharacterSet commentStamp: 'nice 2/12/2019 22:36' prior: 0! - !LazyCharacterSet commentStamp: 'nice 11/30/2017 21:40' prior: 0! A LazyCharacterSet is a kind of CharacterSet which does not know in advance which Character it contains or not. If will lazily evaluate a block on demand if ever one ask whether it includes: a character. It is not feasible to enumerate a LazyCharacterSet, because there are way too many characters. Instance Variables block: <BlockContext | Symbol> byteArrayMapCache: <ByteArray | nil> block - a valuable, answering either true or false when sent the message value: - true means that this set includes the character passed as value: argument. byteArrayMapCache + - a cache holding 0 or 1 for the first 256 character codes - 0 meaning not included, 1 included. This is used in some primitives - - a cache holding 0 or 1 for the first 256 character codes - 0 meaning not included, 1 included. This is used in some priitives ! |
Free forum by Nabble | Edit this page |