~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to doc/progs/sort.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
// Convenience types for common cases
32
32
 
33
 
type IntArray []int
34
 
 
35
 
func (p IntArray) Len() int            { return len(p) }
36
 
func (p IntArray) Less(i, j int) bool  { return p[i] < p[j] }
37
 
func (p IntArray) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
38
 
 
39
 
 
40
 
type Float64Array []float64
41
 
 
42
 
func (p Float64Array) Len() int            { return len(p) }
43
 
func (p Float64Array) Less(i, j int) bool  { return p[i] < p[j] }
44
 
func (p Float64Array) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
45
 
 
46
 
 
47
 
type StringArray []string
48
 
 
49
 
func (p StringArray) Len() int            { return len(p) }
50
 
func (p StringArray) Less(i, j int) bool  { return p[i] < p[j] }
51
 
func (p StringArray) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
 
33
type IntSlice []int
 
34
 
 
35
func (p IntSlice) Len() int            { return len(p) }
 
36
func (p IntSlice) Less(i, j int) bool  { return p[i] < p[j] }
 
37
func (p IntSlice) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
 
38
 
 
39
 
 
40
type Float64Slice []float64
 
41
 
 
42
func (p Float64Slice) Len() int            { return len(p) }
 
43
func (p Float64Slice) Less(i, j int) bool  { return p[i] < p[j] }
 
44
func (p Float64Slice) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
 
45
 
 
46
 
 
47
type StringSlice []string
 
48
 
 
49
func (p StringSlice) Len() int            { return len(p) }
 
50
func (p StringSlice) Less(i, j int) bool  { return p[i] < p[j] }
 
51
func (p StringSlice) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
52
52
 
53
53
 
54
54
// Convenience wrappers for common cases
55
55
 
56
 
func SortInts(a []int)        { Sort(IntArray(a)) }
57
 
func SortFloat64s(a []float64)    { Sort(Float64Array(a)) }
58
 
func SortStrings(a []string)  { Sort(StringArray(a)) }
59
 
 
60
 
 
61
 
func IntsAreSorted(a []int) bool       { return IsSorted(IntArray(a)) }
62
 
func Float64sAreSorted(a []float64) bool   { return IsSorted(Float64Array(a)) }
63
 
func StringsAreSorted(a []string) bool { return IsSorted(StringArray(a)) }
 
56
func SortInts(a []int)        { Sort(IntSlice(a)) }
 
57
func SortFloat64s(a []float64)    { Sort(Float64Slice(a)) }
 
58
func SortStrings(a []string)  { Sort(StringSlice(a)) }
 
59
 
 
60
 
 
61
func IntsAreSorted(a []int) bool       { return IsSorted(IntSlice(a)) }
 
62
func Float64sAreSorted(a []float64) bool   { return IsSorted(Float64Slice(a)) }
 
63
func StringsAreSorted(a []string) bool { return IsSorted(StringSlice(a)) }