summaryrefslogtreecommitdiff
path: root/src/lib/container/array/array.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2008-11-19 16:23:45 -0800
committerRobert Griesemer <gri@golang.org>2008-11-19 16:23:45 -0800
commite2695d9a5a0f37582388af65ace111f30b583475 (patch)
tree5b6fa18c06a87ad8501015b628c456cb6796649b /src/lib/container/array/array.go
parent10893da6fd157d333222ba7ba38bd1865738bb68 (diff)
downloadgolang-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.go11
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]