From e2695d9a5a0f37582388af65ace111f30b583475 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 19 Nov 2008 16:23:45 -0800 Subject: - full support for sorting (assumes array elements implement LessInterface - better test reporting R=r DELTA=43 (24 added, 0 deleted, 19 changed) OCL=19641 CL=19645 --- src/lib/container/array/array.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lib/container/array/array.go') diff --git a/src/lib/container/array/array.go b/src/lib/container/array/array.go index 97f2c4397..95ed6c2ec 100644 --- a/src/lib/container/array/array.go +++ b/src/lib/container/array/array.go @@ -111,6 +111,17 @@ func (p *Array) Pop() Element { // Partial SortInterface support + +export type LessInterface interface { + Less(y Element) bool +} + + +func (p *Array) Less(i, j int) bool { + return p.a[i].(LessInterface).Less(p.a[j]) +} + + func (p *Array) Swap(i, j int) { a := p.a; a[i], a[j] = a[j], a[i] -- cgit v1.2.3