本文整理汇总了Golang中container/vector.Vector.Iter方法的典型用法代码示例。如果您正苦于以下问题:Golang Vector.Iter方法的具体用法?Golang Vector.Iter怎么用?Golang Vector.Iter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类container/vector.Vector
的用法示例。
在下文中一共展示了Vector.Iter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: parseGroups
// parseGroups is used to parse a list of group states.
func parseGroups(lines []string) ([]Group, os.Error) {
var res vector.Vector
for _, line := range lines {
ss := strings.Split(strings.TrimSpace(line), " ", 4)
if len(ss) < 4 {
return nil, ProtocolError("short group info line: " + line)
}
high, err := strconv.Atoi(ss[1])
if err != nil {
return nil, ProtocolError("bad number in line: " + line)
}
low, err := strconv.Atoi(ss[2])
if err != nil {
return nil, ProtocolError("bad number in line: " + line)
}
res.Push(&Group{ss[0], high, low, ss[3]})
}
realres := make([]Group, res.Len())
i := 0
for v := range res.Iter() {
realres[i] = *v.(*Group)
i++
}
return realres, nil
}
示例2: main
func main() {
/* handle all the flags */
flag.Parse()
if flag.NArg() == 0 {
if !*q {
println("No files specified")
}
os.Exit(1)
}
//if neither are set, show both
if !*d && !*D {
*d, *D = true, true
}
//if none are set, show all
if !*i && !*f && !*g && !*t {
*i, *f, *g, *t = true, true, true, true
}
var filter int
if *i {
filter |= Import
}
if *f {
filter |= Func
}
if *g {
filter |= Global
}
if *t {
filter |= Type
}
matcher, err := regexp.Compile(*m)
check(err)
files := flag.Args()
/* process all the files */
var glob vector.Vector
for _, file_name := range files {
info, err := os.Stat(file_name)
check(err)
if info.IsDirectory() {
base := path.Clean(file_name)
dir, err := os.Open(base, os.O_RDONLY, 0664)
defer dir.Close()
check(err)
dirs, err := dir.Readdirnames(-1)
check(err)
none := true
for _, file_name = range dirs {
if !*tests && strings.HasSuffix(file_name, "_test.go") {
continue
}
if strings.HasSuffix(file_name, ".go") {
none = false
glob.Push(doFile(path.Join(base, file_name)))
}
}
if none {
if !*q {
os.Stderr.WriteString("There are no go files in " + base)
}
os.Exit(1)
}
} else if info.IsRegular() {
//file.Close()
glob.Push(doFile(file_name))
} else {
msg := "File " + file_name
msg += " is neither a directory nor a regular file"
if !*q {
os.Stderr.WriteString(msg)
}
os.Exit(1)
}
}
/* display all requested results */
var show bool
for e := range glob.Iter() {
entry := e.(*Declarations)
if !*p {
println(entry.file_name + ":" + entry.package_name)
}
for _, decls := range entry.decls {
show = filter&decls.kind != 0
if show && decls.kind != Import {
show = (*D && decls.public) || (*d && !decls.public)
}
if show && matcher.MatchString(decls.match) {
println(decls.full)
}
//.........这里部分代码省略.........