--- a/Collection.st Wed Jun 04 16:51:00 2014 +0200
+++ b/Collection.st Thu Jun 05 13:25:45 2014 +0200
@@ -328,6 +328,7 @@
^ self == Collection
! !
+
!Collection methodsFor:'Compatibility-Dolphin'!
identityIncludes:anObject
@@ -5021,13 +5022,28 @@
Use the algorithm by R. E. Tarjan from 1972.
Answer an OrderedCollection containing the sorted items"
+ ^ self topologicalSortStable: false
+
+ "Modified: / 05-06-2014 / 12:22:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+topologicalSortStable: sortStable
+ "Sort a partial ordered collection.
+ The receiver consists of tupels defining a partial order.
+ Use the algorithm by R. E. Tarjan from 1972.
+ Answer an OrderedCollection containing the sorted items.
+
+ If sortStable is true, try to make order stable among
+ multiple invocations. Othewise, stability is not guaranteed.
+ "
+
|graph roots sorted count|
"create a graph.
For each node there is an entry containing the number of references
and a list of arcs to other nodes"
- graph := Dictionary new.
+ graph := sortStable ifTrue:[ OrderedDictionary new ] ifFalse:[ Dictionary new ].
self do:[:eachTuple|
|node1|
@@ -5121,6 +5137,8 @@
Array with:eachClass superclass with:eachClass
]) topologicalSort
"
+
+ "Created: / 05-06-2014 / 12:21:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!Collection methodsFor:'statistical functions'!
@@ -5542,11 +5560,11 @@
!Collection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.336 2014-05-12 20:31:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.337 2014-06-05 11:25:45 vrany Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.336 2014-05-12 20:31:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.337 2014-06-05 11:25:45 vrany Exp $'
! !