當前位置: 首頁>>代碼示例>>Golang>>正文


Golang StringVector.Push方法代碼示例

本文整理匯總了Golang中container/vector.StringVector.Push方法的典型用法代碼示例。如果您正苦於以下問題:Golang StringVector.Push方法的具體用法?Golang StringVector.Push怎麽用?Golang StringVector.Push使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在container/vector.StringVector的用法示例。


在下文中一共展示了StringVector.Push方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: intLogc

// Send a closure log message internally
func (log *Logger) intLogc(level int, closure func() string) {
	// Create a vector long enough to not require resizing
	var logto vector.StringVector
	logto.Resize(0, len(log.filterLevels))

	// Determine if any logging will be done
	for filt := range log.filterLevels {
		if level >= log.filterLevels[filt] {
			logto.Push(filt)
		}
	}

	// Only log if a filter requires it
	if len(logto) > 0 {
		// Determine caller func
		pc, _, lineno, ok := runtime.Caller(2)
		src := ""
		if ok {
			src = fmt.Sprintf("%s:%d", runtime.FuncForPC(pc).Name(), lineno)
		}

		// Make the log record from the closure's return
		rec := newLogRecord(level, src, closure())

		// Dispatch the logs
		for _, filt := range logto {
			log.filterLogWriters[filt].LogWrite(rec)
		}
	}
}
開發者ID:Kissaki,項目名稱:log4go,代碼行數:31,代碼來源:log4go.go

示例2: signatureBase

func signatureBase(httpMethod string, base_uri string, params map[string]string) string {
	var buf bytes.Buffer

	buf.WriteString(httpMethod)
	buf.WriteString("&")
	buf.WriteString(URLEscape(base_uri))
	buf.WriteString("&")

	var keys vector.StringVector
	for k, _ := range params {
		keys.Push(k)
	}

	sort.SortStrings(keys)
	for i, k := range keys {
		v := params[k]
		buf.WriteString(URLEscape(k))
		buf.WriteString("%3D")
		buf.WriteString(URLEscape(v))
		//don't include the dangling %26
		if i < len(params)-1 {
			buf.WriteString("%26")
		}
		i++
	}
	return buf.String()
}
開發者ID:gmarik,項目名稱:twitterstream,代碼行數:27,代碼來源:oauth.go

示例3: parseParamsInUnquotedSubstring

func parseParamsInUnquotedSubstring(s string, name2value map[string]string) (lastKeyword string) {
	var words vector.StringVector

	for {
		index := strings.IndexAny(s, "= \n\r\t")
		if index == -1 {
			break
		}

		word := s[:index]
		if word != "" {
			words.Push(word)
		}
		s = s[index+1:]
	}
	if len(s) > 0 {
		words.Push(s)
	}

	for i := 0; i < len(words)-1; i += 2 {
		name2value[words[i]] = words[i+1]
	}

	if len(words) > 0 && len(words)%2 == 1 {
		lastKeyword = words[len(words)-1]
	}

	return
}
開發者ID:lalitjsraks,項目名稱:go-pgsql,代碼行數:29,代碼來源:conn.go

示例4: importConnections

func (p *Pipeline) importConnections(client oauth2_client.OAuth2Client, ds DataStoreService, cs ContactsService, dsocialUserId string, allowAdd, allowDelete, allowUpdate bool, groupMappings map[string]*list.List, contactChangesetIds *vector.StringVector) (err os.Error) {
	checkGroupsInContacts := cs.ContactInfoIncludesGroups()
	var nextToken NextToken = "blah"
	for connections, useNextToken, err := cs.RetrieveConnections(client, ds, dsocialUserId, nil); (len(connections) > 0 && nextToken != nil) || err != nil; connections, useNextToken, err = cs.RetrieveConnections(client, ds, dsocialUserId, nextToken) {
		if err != nil {
			break
		}
		for _, connection := range connections {
			contact, err := cs.RetrieveContact(client, ds, dsocialUserId, connection.ExternalContactId)
			if err != nil {
				break
			}
			finalContact, changesetId, err := p.contactImport(cs, ds, dsocialUserId, contact, allowAdd, allowDelete, allowUpdate)
			if changesetId != "" {
				contactChangesetIds.Push(changesetId)
			}
			if checkGroupsInContacts && finalContact != nil && finalContact != nil && finalContact.GroupReferences != nil && len(finalContact.GroupReferences) > 0 {
				p.addContactToGroupMappings(groupMappings, finalContact)
			}
			if err != nil {
				break
			}
		}
		nextToken = useNextToken
		if err != nil {
			break
		}
	}
	return
}
開發者ID:pombredanne,項目名稱:dsocial.go,代碼行數:30,代碼來源:pipeline.go

示例5: iterFiles

//loops through root and subfolders to locate files with
//extensions specified in settings file
func (this *Settings) iterFiles(f string, pages *vector.StringVector) (err os.Error) {
	file, err := os.OpenFile(f, os.O_RDONLY, 0666)
	if err != nil {
		println(err.String())
		return
	}
	stat, er := file.Stat()
	if er != nil {
		err = er
		return
	}
	if stat.IsDirectory() {
		fmt.Println("iterFiles55555")
		dirs, err := file.Readdir(-1)
		if err != nil {
			return
		}
		for _, d := range dirs {
			this.iterFiles(path.Join(file.Name(), d.Name), pages)
		}
	} else {
		if hasExt(file.Name(), this.Data["extensions"]) {
			err = generate(file.Name())
			fmt.Println("iterFiles_eekkkk")
			if err != nil {
				return
			}
			pages.Push(file.Name())
		}
		file.Close()
	}
	return
}
開發者ID:santinopnipa,項目名稱:SUT_gopages,代碼行數:35,代碼來源:util.go

示例6: GenerateTestMain

// GenerateTestMain returns the source code for a test program that will run
// the specified test functions from the specified package.
func GenerateTestMain(packageName string, funcs *set.StringSet) string {
	var funcVec vector.StringVector
	for val := range funcs.Iter() {
		funcVec.Push(val)
	}

	result := ""
	result += "package main\n\n"
	result += "import \"testing\"\n"

	if funcVec.Len() > 0 {
		result += fmt.Sprintf("import \"./%s\"\n\n", packageName)
	}

	result += "var tests = []testing.Test {\n"
	for _, val := range funcVec.Data() {
		result += fmt.Sprintf("\ttesting.Test{\"%s\", %s.%s},\n", val, packageName, val)
	}

	result += "}\n\n"
	result += "func main() {\n"
	result += "\ttesting.Main(tests)\n"
	result += "}\n"

	return result
}
開發者ID:jacobsa,項目名稱:igo,代碼行數:28,代碼來源:generate.go

示例7: outputDot

func (p *Trie) outputDot(vec *vector.StringVector, rune int, serial int64, rgen *rand.Rand) {
	this := make([]byte, 10)
	child := make([]byte, 10)

	utf8.EncodeRune(this, rune)

	thisChar := string(this[0])

	if serial == -1 {
		thisChar = "root"
	}

	for childRune, childNode := range p.children {
		utf8.EncodeRune(child, childRune)
		childSerial := rgen.Int63()
		childNodeStr := fmt.Sprintf("\"%s(%d)\"", string(child[0]), childSerial)
		var notation string

		if string(child[0]) == "/" {
			notation = fmt.Sprintf("[label=\"%s\" shape=box color=red]", string(child[0]))
		} else {
			notation = fmt.Sprintf("[label=\"%s\"]", string(child[0]))
		}
		vec.Push(fmt.Sprintf("\t%s %s\n\t\"%s(%d)\" -> \"%s(%d)\"", childNodeStr, notation, thisChar, serial, string(child[0]), childSerial))
		childNode.outputDot(vec, childRune, childSerial, rgen)
	}
}
開發者ID:alangenfeld,項目名稱:cs639,代碼行數:27,代碼來源:trie.go

示例8: ReadDotLines

// ReadDotLines reads a dot-encoding and returns a slice
// containing the decoded lines, with the final \r\n or \n elided from each.
//
// See the documentation for the DotReader method for details about dot-encoding.
func (r *Reader) ReadDotLines() ([]string, os.Error) {
	// We could use ReadDotBytes and then Split it,
	// but reading a line at a time avoids needing a
	// large contiguous block of memory and is simpler.
	var v vector.StringVector
	var err os.Error
	for {
		var line string
		line, err = r.ReadLine()
		if err != nil {
			if err == os.EOF {
				err = io.ErrUnexpectedEOF
			}
			break
		}

		// Dot by itself marks end; otherwise cut one dot.
		if len(line) > 0 && line[0] == '.' {
			if len(line) == 1 {
				break
			}
			line = line[1:]
		}
		v.Push(line)
	}
	return v, err
}
開發者ID:IntegerCompany,項目名稱:linaro-android-gcc,代碼行數:31,代碼來源:reader.go

示例9: Log

// Send a log message manually
func (log *Logger) Log(level int, source, message string) {
	// Create a vector long enough to not require resizing
	var logto vector.StringVector
	logto.Resize(0, len(log.filterLevels))

	// Determine if any logging will be done
	for filt := range log.filterLevels {
		if level >= log.filterLevels[filt] {
			logto.Push(filt)
		}
	}

	// Only log if a filter requires it
	if len(logto) > 0 {
		// Make the log record
		rec := newLogRecord(level, source, message)

		// Dispatch the logs
		for _, filt := range logto {
			lw := log.filterLogWriters[filt]
			if lw.Good() {
				lw.LogWrite(rec)
			}
		}
	}
}
開發者ID:Kissaki,項目名稱:log4go,代碼行數:27,代碼來源:log4go.go

示例10: prepare

// Reordering, compressing, optimization.
func prepare(ops []op) string {
	var cmds vector.StringVector
	for _, o := range ops {
		cmds.Push(o.cmd)
	}

	return strings.Join([]string(cmds), "")
}
開發者ID:schmichael,項目名稱:beanstalk.go,代碼行數:9,代碼來源:beanstalk.go

示例11: BenchmarkMGet

func BenchmarkMGet(b *testing.B) {
	client.Set("bmg", []byte("hi"))
	var vals vector.StringVector
	for i := 0; i < b.N; i++ {
		vals.Push("bmg")
	}
	client.Mget(vals...)
	client.Del("bmg")
}
開發者ID:rjmcguire,項目名稱:redis.go,代碼行數:9,代碼來源:redis_test.go

示例12: getSorted

func getSorted(set *StringSet) []string {
	var sorted vector.StringVector
	for val := range set.Iter() {
		sorted.Push(val)
	}

	sort.SortStrings(sorted)
	return sorted.Data()
}
開發者ID:jacobsa,項目名稱:igo,代碼行數:9,代碼來源:set_test.go

示例13: ExecutionModelSpec

func ExecutionModelSpec(c nanospec.Context) {

	c.Specify("Specs with children, but without siblings, are executed fully on one run", func() {

		c.Specify("Case: no children", func() {
			runSpecWithContext(DummySpecWithNoChildren, newInitialContext())
			c.Expect(testSpy).Equals("root")
		})
		c.Specify("Case: one child", func() {
			runSpecWithContext(DummySpecWithOneChild, newInitialContext())
			c.Expect(testSpy).Equals("root,a")
		})
		c.Specify("Case: nested children", func() {
			runSpecWithContext(DummySpecWithNestedChildren, newInitialContext())
			c.Expect(testSpy).Equals("root,a,aa")
		})
	})

	c.Specify("Specs with siblings are executed only one sibling at a time", func() {

		c.Specify("Case: on initial run, the 1st child is executed", func() {
			runSpecWithContext(DummySpecWithTwoChildren, newInitialContext())
			c.Expect(testSpy).Equals("root,a")
		})
		c.Specify("Case: explicitly execute the 1st child", func() {
			runSpecWithContext(DummySpecWithTwoChildren, newExplicitContext([]int{0}))
			c.Expect(testSpy).Equals("root,a")
		})
		c.Specify("Case: explicitly execute the 2nd child", func() {
			runSpecWithContext(DummySpecWithTwoChildren, newExplicitContext([]int{1}))
			c.Expect(testSpy).Equals("root,b")
		})
	})

	c.Specify("Specs with nested siblings: eventually all siblings are executed, one at a time, in isolation", func() {
		r := NewRunner()
		r.AddSpec(DummySpecWithMultipleNestedChildren)

		// Execute manually instead of calling Run(), in order to avoid running
		// the specs multi-threadedly, which would mess up the test spy.
		runs := new(vector.StringVector)
		for r.hasScheduledTasks() {
			resetTestSpy()
			r.executeNextScheduledTask()
			runs.Push(testSpy)
		}
		sort.Sort(runs)

		c.Expect(runs.Len()).Equals(5)
		c.Expect(runs.At(0)).Equals("root,a,aa")
		c.Expect(runs.At(1)).Equals("root,a,ab")
		c.Expect(runs.At(2)).Equals("root,b,ba")
		c.Expect(runs.At(3)).Equals("root,b,bb")
		c.Expect(runs.At(4)).Equals("root,b,bc")
	})
}
開發者ID:boggle,項目名稱:gospec,代碼行數:56,代碼來源:execution_model_test.go

示例14: removeEmptyStrings

func removeEmptyStrings(arr []string) []string {
	sv := new(vector.StringVector)
	sv.Resize(0, len(arr))
	for _, s := range arr {
		if s != "" {
			sv.Push(s)
		}
	}
	return *sv
}
開發者ID:pombredanne,項目名稱:dsocial.go,代碼行數:10,代碼來源:util.go

示例15: Matches

func (self *Regex) Matches(s string) []string {
	res := new(vector.StringVector)
	self.l.StartString(s)
	for !self.l.Eof() {
		if self.l.Next() == 0 {
			res.Push(self.l.String())
		}
	}
	return res.Data()
}
開發者ID:ypb,項目名稱:bwl,代碼行數:10,代碼來源:regex.go


注:本文中的container/vector.StringVector.Push方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。