OSDN Git Service

Update Go library to r60.
[pf3gnuchains/gcc-fork.git] / libgo / go / container / vector / defs.go
1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package vector implements containers for managing sequences of elements.
6 // Vectors grow and shrink dynamically as necessary.
7 package vector
8
9 // Vector is a container for numbered sequences of elements of type interface{}.
10 // A vector's length and capacity adjusts automatically as necessary.
11 // The zero value for Vector is an empty vector ready to use.
12 type Vector []interface{}
13
14 // IntVector is a container for numbered sequences of elements of type int.
15 // A vector's length and capacity adjusts automatically as necessary.
16 // The zero value for IntVector is an empty vector ready to use.
17 type IntVector []int
18
19 // StringVector is a container for numbered sequences of elements of type string.
20 // A vector's length and capacity adjusts automatically as necessary.
21 // The zero value for StringVector is an empty vector ready to use.
22 type StringVector []string
23
24 // Initial underlying array size
25 const initialSize = 8
26
27 // Partial sort.Interface support
28
29 // LessInterface provides partial support of the sort.Interface.
30 type LessInterface interface {
31         Less(y interface{}) bool
32 }
33
34 // Less returns a boolean denoting whether the i'th element is less than the j'th element.
35 func (p *Vector) Less(i, j int) bool { return (*p)[i].(LessInterface).Less((*p)[j]) }
36
37 // sort.Interface support
38
39 // Less returns a boolean denoting whether the i'th element is less than the j'th element.
40 func (p *IntVector) Less(i, j int) bool { return (*p)[i] < (*p)[j] }
41
42 // Less returns a boolean denoting whether the i'th element is less than the j'th element.
43 func (p *StringVector) Less(i, j int) bool { return (*p)[i] < (*p)[j] }