当前位置: 首页>>代码示例>>Golang>>正文


Golang StringVector.Pop方法代码示例

本文整理汇总了Golang中container/vector.StringVector.Pop方法的典型用法代码示例。如果您正苦于以下问题:Golang StringVector.Pop方法的具体用法?Golang StringVector.Pop怎么用?Golang StringVector.Pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在container/vector.StringVector的用法示例。


在下文中一共展示了StringVector.Pop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: checkCyclic

func (ctxt *context) checkCyclic(c *command, path *vector.StringVector) {
	fmt.Printf("checkCyclic %s\n", c.name)
	if c.visit {
		ctxt.fail("cyclic dependency at %s, path %v", c.name, path)
	}
	c.visit = true
	path.Push(c.name)
	for _, e := range c.conns {
		if e.gender == Female {
			ctxt.checkCyclic(e.male.cmd, path)
		}
	}
	path.Pop()
	c.visit = false
}
开发者ID:zxpbenson,项目名称:rog-go,代码行数:15,代码来源:abc.go

示例2: rpnstr

// convert rpn to nice infix notation and string
// the r must be valid rpn form
func rpnstr(r []int) (ret string) {
	s := new(vector.StringVector)
	for k, t := range r {
		switch t {
		case ADD, SUB, MUL, DIV:
			a := s.Pop()
			b := s.Pop()
			if k == len(r)-1 {
				s.Push(b + mop[t] + a)
			} else {
				s.Push("(" + b + mop[t] + a + ")")
			}
		default:
			s.Push(strconv.Itoa(t))
		}
	}
	for _, v := range *s {
		ret += v
	}
	return
}
开发者ID:semyazza,项目名称:gobook,代码行数:23,代码来源:permrec.go

示例3: main

func main() {
	flag.Parse()

	if flag.NArg() != 2 {
		printUsageAndExit()
	}

	command := flag.Arg(0)
	if command != "build" && command != "test" {
		printUsageAndExit()
	}

	// Grab dependency and file information for every local package, starting
	// with the specified one. We consider a package local if it starts with "./".
	requiredFiles := make(map[string]*set.StringSet)
	packageDeps := make(map[string]*set.StringSet)

	specifiedPackage := flag.Arg(1)
	var remainingPackages vector.StringVector
	remainingPackages.Push(specifiedPackage)

	for remainingPackages.Len() > 0 {
		packageName := remainingPackages.Pop()

		// Have we already processed this directory?
		_, alreadyDone := packageDeps[packageName]
		if alreadyDone {
			continue
		}

		dir := "./" + packageName
		dirInfo := build.GetDirectoryInfo(dir)
		if dirInfo.PackageName == "" {
			fmt.Printf("Couldn't find .go files to build in directory: %s\n", dir)
			os.Exit(1)
		}

		// Stash information about this package, and add its local dependencies to
		// the queue.
		requiredFiles[packageName] = dirInfo.Files
		packageDeps[packageName] = dirInfo.Deps

		// If we're testing and this is the package under test, also add its test
		// files and dependencies.
		if packageName == specifiedPackage && command == "test" {
			requiredFiles[packageName].Union(dirInfo.TestFiles)
			packageDeps[packageName].Union(dirInfo.TestDeps)
		}

		for dep := range packageDeps[packageName].Iter() {
			remainingPackages.Push(dep)
		}
	}

	// Order the packages by their dependencies.
	totalOrder := deps.BuildTotalOrder(packageDeps)
	fmt.Println("Found these packages to compile:")
	for _, packageName := range totalOrder {
		fmt.Printf("  %s\n", packageName)
	}

	// Create a directory to hold outputs, deleting the old one first.
	os.RemoveAll("igo-out")
	os.Mkdir("igo-out", 0700)

	// Compile each of the packages in turn.
	for _, currentPackage := range totalOrder {
		fmt.Printf("\nCompiling package: %s\n", currentPackage)
		compileFiles(requiredFiles[currentPackage], currentPackage)
	}

	// If this is a binary, also link it.
	if build.GetDirectoryInfo(specifiedPackage).PackageName == "main" {
		linkBinary(specifiedPackage)
	}

	// If we're testing, create a test runner, build it, and run it.
	if command == "test" {
		const outputFile = "igo-out/test_runner.go"
		testFuncs := build.GetDirectoryInfo(specifiedPackage).TestFuncs
		code := test.GenerateTestMain(specifiedPackage, testFuncs)
		err := ioutil.WriteFile("igo-out/test_runner.go", strings.Bytes(code), 0600)
		if err != nil {
			panic(err)
		}

		var files set.StringSet
		files.Insert("igo-out/test_runner.go")
		compileFiles(&files, "test_runner")
		linkBinary("test_runner")

		if !executeCommand("igo-out/test_runner", []string{}, "") {
			os.Exit(1)
		}
	}
}
开发者ID:jacobsa,项目名称:igo,代码行数:96,代码来源:main.go


注:本文中的container/vector.StringVector.Pop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。