--- a/SequenceableCollection.st Mon Apr 12 18:14:30 2004 +0200
+++ b/SequenceableCollection.st Mon Apr 12 18:15:28 2004 +0200
@@ -1126,11 +1126,12 @@
!SequenceableCollection methodsFor:'comparing'!
< aCollection
- "compare two collections"
+ "compare two sequenceable collections"
- |size "{ Class:SmallInteger }"
- aCollectionSize "{ Class:SmallInteger }"
- min "{ Class:SmallInteger }"|
+ |size "{ Class: SmallInteger }"
+ aCollectionSize "{ Class: SmallInteger }"
+ min "{ Class: SmallInteger }"
+ v1 v2|
size := self size.
aCollectionSize := aCollection size.
@@ -1140,10 +1141,10 @@
min := aCollectionSize
].
- 1 to: min do: [:i| |v1 v2|
+ 1 to: min do: [:i|
v1 := self at: i.
v2 := aCollection at: i.
- (v1 == v2 and:[v1 = v2]) ifFalse:[^ v1 < v2]
+ (v1 == v2 or:[v1 = v2]) ifFalse:[^ v1 < v2]
].
^ size < aCollectionSize
@@ -1152,15 +1153,51 @@
#(1 2 3) < #(2)
#(1 2 3) < #()
#(1 2 3) < #(1 2 3)
- "
+
+ |a b|
+
+ a := 'hello world'.
+ b := a copy.
+ Time millisecondsToRun:[
+ 1000000 timesRepeat:[
+ a < b
+ ]
+ ]
+
+ |a b|
+
+ a := CharacterArray fromString:'hello world'.
+ b := a copy.
+ Time millisecondsToRun:[
+ 1000000 timesRepeat:[
+ a < b
+ ]
+ ]
+
+ |a b|
+
+ a := #[1 2 3 4 5 6 7 8 9 10 11].
+ b := a copy.
+ Time millisecondsToRun:[
+ 1000000 timesRepeat:[
+ a < b
+ ]
+ ]
+ "
+!
+
+<= aCollection
+ "Compare the receiver with the argument and return true if the
+ receiver is less than or equal to the argument. Otherwise return false"
+
+ ^ (aCollection < self) not
!
= aCollection
"return true if the receiver and aCollection represent collections
with equal contents."
- |index "{ Class: SmallInteger }"
- stop "{ Class: SmallInteger }" |
+ | stop "{ Class: SmallInteger }" |
(aCollection == self) ifTrue:[^true].
(aCollection isSequenceable) ifFalse:[^false].
@@ -1168,10 +1205,8 @@
stop := self size.
stop == (aCollection size) ifFalse:[^false].
- index := 1.
- [index <= stop] whileTrue:[
+ 1 to:stop do:[:index|
(self at:index) = (aCollection at:index) ifFalse:[^false].
- index := index + 1
].
^ true
@@ -1183,6 +1218,22 @@
"
!
+> aCollection
+ "Compare the receiver with the argument and return true if the
+ receiver is greater than the argument.
+ Otherwise return false."
+
+ ^ aCollection < self
+!
+
+>= aCollection
+ "Compare the receiver with the argument and return true if the
+ receiver is greater than or equal to the argument.
+ Otherwise return false."
+
+ ^ (self < aCollection) not
+!
+
commonPrefixWith:aCollection
"return the common prefix of myself and the argument, aCollection.
If there is none, an empty collection is returned."
@@ -6428,7 +6479,7 @@
!SequenceableCollection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.206 2004-03-30 18:46:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.207 2004-04-12 16:15:28 stefan Exp $'
! !
SequenceableCollection initialize!