--- a/Collection.st Fri Apr 07 10:08:19 2000 +0200
+++ b/Collection.st Fri Apr 07 10:09:58 2000 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
Object subclass:#Collection
instanceVariableNames:''
classVariableNames:'InvalidKeySignal EmptyCollectionSignal ValueNotFoundSignal
@@ -1851,6 +1853,10 @@
!Collection methodsFor:'queries'!
+defaultElement
+ ^ nil
+!
+
isCollection
"return true, if the receiver is some kind of collection;
true is returned here - the method is redefined from Object."
@@ -1871,6 +1877,25 @@
"Created: 13.4.1996 / 12:35:55 / cg"
!
+isSortedBy:aBlock
+ "return true, if my elements are sorted (already) by the given criterion (sortBlock).
+ Collections which hold their elements in sorted order
+ should return true. Some algorithms (quicksort) degenerate when
+ operating on sorted collections and can be avoided if this information
+ is given. The default returned here (false) should not hurt.
+ I.e. you should NEVER depend on that in your application."
+
+ ^ false
+
+!
+
+isSortedCollection
+ "return true, if the receiver is a sortedCollection."
+
+ ^ false
+
+!
+
longestCommonPrefix
"return the longest common prefix of my elements.
Typically used with string collections."
@@ -2081,6 +2106,6 @@
!Collection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.97 2000-02-17 11:05:15 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.98 2000-04-07 08:09:58 cg Exp $'
! !
Collection initialize!
--- a/SortedCollection.st Fri Apr 07 10:08:19 2000 +0200
+++ b/SortedCollection.st Fri Apr 07 10:09:58 2000 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
OrderedCollection subclass:#SortedCollection
instanceVariableNames:'sortBlock'
classVariableNames:'DefaultSortBlock'
@@ -302,7 +304,7 @@
|addedCollection s|
- (aCollection isSorted
+ (aCollection isSortedCollection
and:[aCollection sortBlock == sortBlock]) ifTrue:[
addedCollection := aCollection
] ifFalse:[
@@ -393,7 +395,7 @@
newContentsArray := Array new:(n1 + n2).
destIndex := 1.
- aSortedCollection isSorted ifTrue:[
+ (aSortedCollection isSortedBy:sortBlock) ifTrue:[
contentsArray2 := aSortedCollection contentsArray.
srcIndex2 := aSortedCollection firstIndex.
] ifFalse:[
@@ -623,9 +625,24 @@
!SortedCollection methodsFor:'queries'!
isSorted
+ "return true. if my elements are sorted"
+
^ true
+!
+
+isSortedBy:aBlock
+ "return true, if my elements are sorted (already) by the given criterion (sortBlock)."
- "Created: 13.4.1996 / 12:36:29 / cg"
+ aBlock == sortBlock ifTrue:[^ true].
+ ^ super isSortedBy:aBlock
+
+
+!
+
+isSortedCollection
+ "return true. if I am a sorted collection"
+
+ ^ true
! !
!SortedCollection methodsFor:'searching'!
@@ -797,6 +814,6 @@
!SortedCollection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/SortedCollection.st,v 1.43 1999-12-02 11:21:49 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/SortedCollection.st,v 1.44 2000-04-07 08:09:30 cg Exp $'
! !
SortedCollection initialize!