diff options
author | Robert Griesemer <gri@golang.org> | 2008-11-19 16:23:45 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2008-11-19 16:23:45 -0800 |
commit | e2695d9a5a0f37582388af65ace111f30b583475 (patch) | |
tree | 5b6fa18c06a87ad8501015b628c456cb6796649b /src/lib/container/array/array.go | |
parent | 10893da6fd157d333222ba7ba38bd1865738bb68 (diff) | |
download | golang-e2695d9a5a0f37582388af65ace111f30b583475.tar.gz |
- 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
Diffstat (limited to 'src/lib/container/array/array.go')
-rw-r--r-- | src/lib/container/array/array.go | 11 |
1 files changed, 11 insertions, 0 deletions
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] |