--- a/SequenceableCollection.st Fri Mar 12 19:01:59 2004 +0100
+++ b/SequenceableCollection.st Fri Mar 12 19:11:58 2004 +0100
@@ -1074,34 +1074,6 @@
!SequenceableCollection methodsFor:'comparing'!
-< aCollection
- "compare two collections"
-
- |size aCollectionSize min "{ Class:SmallInteger }"|
-
- size := self size.
- aCollectionSize := aCollection size.
- size < aCollectionSize ifTrue:[
- min := size
- ] ifFalse:[
- min := aCollectionSize
- ].
-
- 1 to: min do: [:i| |v1 v2|
- v1 := self at: i.
- v2 := aCollection at: i.
- v1 == v2 ifFalse:[^ v1 < v2]
- ].
- ^ size < aCollectionSize
-
- "
- #(1 2 3) < #(1)
- #(1 2 3) < #(2)
- #(1 2 3) < #()
- #(1 2 3) < #(1 2 3)
- "
-!
-
= aCollection
"return true if the receiver and aCollection represent collections
with equal contents."
@@ -1130,6 +1102,36 @@
"
!
+> aCollection
+ "compare two collections"
+
+ |size "{ Class:SmallInteger }"
+ aCollectionSize "{ Class:SmallInteger }"
+ min "{ Class:SmallInteger }"|
+
+ size := self size.
+ aCollectionSize := aCollection size.
+ size < aCollectionSize ifTrue:[
+ min := size
+ ] ifFalse:[
+ min := aCollectionSize
+ ].
+
+ 1 to: min do: [:i| |v1 v2|
+ v1 := self at: i.
+ v2 := aCollection at: i.
+ (v1 == v2 and:[v1 = v2]) ifFalse:[^ v1 > v2]
+ ].
+ ^ size > aCollectionSize
+
+ "
+ #(1 2 3) > #(1)
+ #(1 2 3) > #(2)
+ #(1 2 3) > #()
+ #(1 2 3) > #(1 2 3)
+ "
+!
+
commonPrefixWith:aCollection
"return the common prefix of myself and the argument, aCollection.
If there is none, an empty collection is returned."
@@ -4001,7 +4003,10 @@
quickSortFrom:inBegin to:inEnd
"actual quicksort worker for sort-message.
Simulates recursion in a stack, to avoid recursion overflow
- with degenerated collections."
+ with degenerated collections.
+
+ Use #> for element comparisons, since this is the (fastest) base
+ method in Magnitude, and the others may be defined by sending #>."
|begin "{ Class: SmallInteger }"
end "{ Class: SmallInteger }"
@@ -4022,8 +4027,8 @@
middleElement := self at:((b + e) // 2).
[b < e] whileTrue:[
- [b < end and:[(self at:b) < middleElement]] whileTrue:[b := b + 1].
- [e > begin and:[middleElement < (self at:e)]] whileTrue:[e := e - 1].
+ [b < end and:[middleElement > (self at:b)]] whileTrue:[b := b + 1].
+ [e > begin and:[(self at:e) > middleElement]] whileTrue:[e := e - 1].
(b <= e) ifTrue:[
(b == e) ifFalse:[
@@ -4273,7 +4278,10 @@
quickSortFrom:inBegin to:inEnd with:aCollection
"actual quicksort worker for sortWith-message.
Simulates recursion in a stack, to avoid recursion overflow
- with degenerated collections."
+ with degenerated collections.
+
+ Use #> for element comparisons, since this is the (fastest) base
+ method in Magnitude, and the others may be defined by sending #>."
|begin "{ Class: SmallInteger }"
end "{ Class: SmallInteger }"
@@ -4294,8 +4302,8 @@
middleElement := self at:((b + e) // 2).
[b < e] whileTrue:[
- [b < end and:[(self at:b) < middleElement]] whileTrue:[b := b + 1].
- [e > begin and:[middleElement < (self at:e)]] whileTrue:[e := e - 1].
+ [b < end and:[middleElement > (self at:b)]] whileTrue:[b := b + 1].
+ [e > begin and:[(self at:e) > middleElement]] whileTrue:[e := e - 1].
(b <= e) ifTrue:[
(b == e) ifFalse:[
@@ -4332,6 +4340,14 @@
Since the middle element is choosen, this worst case is very unlikely
to be encountered."
+ <resource:#obsolete>
+
+ self obsoleteMethodWarning:'use quickSortFrom:to:sortBlock:with:'.
+
+ "/ code was never used - use regular sort for backward compatibility
+ ^ self quickSortFrom:inBegin to:inEnd sortBlock:sortBlock with:aCollection
+
+
"/ |begin "{ Class: SmallInteger }"
"/ end "{ Class: SmallInteger }"
"/ b "{ Class: SmallInteger }"
@@ -4380,10 +4396,6 @@
"/ ].
"/ (begin < e) ifTrue:[self randomizedQuickSortFrom:begin to:e sortBlock:sortBlock with:aCollection].
"/ (b < end) ifTrue:[self randomizedQuickSortFrom:b to:end sortBlock:sortBlock with:aCollection]
-
- "/ code was never used - use regular sort for backward compatibility
- ^ self quickSortFrom:inBegin to:inEnd sortBlock:sortBlock with:aCollection
-
!
randomizedQuickSortFrom:inBegin to:inEnd with:aCollection
@@ -4399,6 +4411,13 @@
Since the middle element is choosen, this worst case is very unlikely
to be encountered."
+ <resource:#obsolete>
+
+ self obsoleteMethodWarning:'use quickSortFrom:to:with:'.
+ "/ code was never used - use regular sort for backward compatibility
+ ^ self quickSortFrom:inBegin to:inEnd with:aCollection
+
+
"/ |begin "{ Class: SmallInteger }"
"/ end "{ Class: SmallInteger }"
"/ b "{ Class: SmallInteger }"
@@ -4450,10 +4469,6 @@
"/
"/ "Modified: 21.8.1997 / 18:30:19 / cg"
"/ "Created: 21.8.1997 / 18:34:23 / cg"
-
- "/ code was never used - use regular sort for backward compatibility
- ^ self quickSortFrom:inBegin to:inEnd with:aCollection
-
! !
!SequenceableCollection methodsFor:'queries'!
@@ -5831,7 +5846,7 @@
stop := self size.
(stop > 1) ifTrue:[
- self mergeSort:[:a :b | a < b ] from:1 to:stop
+ self mergeSort:[:a :b | b > a ] from:1 to:stop
]
"
@@ -6338,7 +6353,7 @@
!SequenceableCollection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.201 2004-03-05 20:01:22 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.202 2004-03-12 18:11:13 stefan Exp $'
! !
SequenceableCollection initialize!