diff -r e99d0f95c925 -r 93f8b0cc734f SequenceableCollection.st --- a/SequenceableCollection.st Fri Mar 12 19:46:41 2004 +0100 +++ b/SequenceableCollection.st Fri Mar 12 19:48:55 2004 +0100 @@ -1074,6 +1074,36 @@ !SequenceableCollection methodsFor:'comparing'! +< 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) + " +! + = aCollection "return true if the receiver and aCollection represent collections with equal contents." @@ -1102,36 +1132,6 @@ " ! -> 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." @@ -4005,8 +4005,8 @@ Simulates recursion in a stack, to avoid recursion overflow with degenerated collections. - Use #> for element comparisons, since this is the (fastest) base - method in Magnitude, and the others may be defined by sending #>." + 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 }" @@ -4027,8 +4027,8 @@ middleElement := self at:((b + e) // 2). [b < e] whileTrue:[ - [b < end and:[middleElement > (self at:b)]] whileTrue:[b := b + 1]. - [e > begin and:[(self at:e) > middleElement]] whileTrue:[e := e - 1]. + [b < end and:[(self at:b) < middleElement]] whileTrue:[b := b + 1]. + [e > begin and:[middleElement < (self at:e)]] whileTrue:[e := e - 1]. (b <= e) ifTrue:[ (b == e) ifFalse:[ @@ -4280,8 +4280,8 @@ Simulates recursion in a stack, to avoid recursion overflow with degenerated collections. - Use #> for element comparisons, since this is the (fastest) base - method in Magnitude, and the others may be defined by sending #>." + 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 }" @@ -4302,8 +4302,8 @@ middleElement := self at:((b + e) // 2). [b < e] whileTrue:[ - [b < end and:[middleElement > (self at:b)]] whileTrue:[b := b + 1]. - [e > begin and:[(self at:e) > middleElement]] whileTrue:[e := e - 1]. + [b < end and:[(self at:b) < middleElement]] whileTrue:[b := b + 1]. + [e > begin and:[middleElement < (self at:e)]] whileTrue:[e := e - 1]. (b <= e) ifTrue:[ (b == e) ifFalse:[ @@ -5846,7 +5846,7 @@ stop := self size. (stop > 1) ifTrue:[ - self mergeSort:[:a :b | b > a ] from:1 to:stop + self mergeSort:[:a :b | a < b] from:1 to:stop ] " @@ -6353,7 +6353,7 @@ !SequenceableCollection class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.202 2004-03-12 18:11:13 stefan Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.203 2004-03-12 18:48:23 stefan Exp $' ! ! SequenceableCollection initialize!