本文整理匯總了Golang中container/vector.StringVector.AppendVector方法的典型用法代碼示例。如果您正苦於以下問題:Golang StringVector.AppendVector方法的具體用法?Golang StringVector.AppendVector怎麽用?Golang StringVector.AppendVector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類container/vector.StringVector
的用法示例。
在下文中一共展示了StringVector.AppendVector方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: variances
func (p *wmDecisionCore) variances() []string {
var v vector.StringVector
var ctp []MediaTypeHandler
var ep []EncodingHandler
var cp []CharsetHandler
arr := make([]string, 1)
arr[0] = "*"
ctp, p.req, p.cxt, _, _ = p.handler.ContentTypesProvided(p.req, p.cxt)
ep, p.req, p.cxt, _, _ = p.handler.EncodingsProvided(arr, p.req, p.cxt)
cp, p.req, p.cxt, _, _ = p.handler.CharsetsProvided(arr, p.req, p.cxt)
if len(ctp) > 1 {
v.Push("Accept")
}
if len(ep) > 1 {
v.Push("Accept-Encoding")
}
if len(cp) > 1 {
v.Push("Accept-Charset")
}
var headers []string
headers, p.req, p.cxt, _, _ = p.handler.Variances(p.req, p.cxt)
v2 := vector.StringVector(headers)
v.AppendVector(&v2)
return v
}
示例2: ExpandFiles
// Expand a list of files and directories
func ExpandFiles(files []string) []string {
flatFiles := new(vector.StringVector)
for _, filename := range files {
info, err := os.Stat(filename)
if err != nil {
continue
}
if info.IsDirectory() {
flatFiles.AppendVector(listFiles(filename))
} else {
flatFiles.Push(filename)
}
}
return *flatFiles
}
示例3: buildMembers
// Internal output-building function used by Members()
func (p *Trie) buildMembers(prefix string) *vector.StringVector {
strList := new(vector.StringVector)
if p.leaf {
strList.Push(prefix)
}
// for each child, go grab all suffixes
for rune, child := range p.children {
buf := make([]byte, 4)
numChars := utf8.EncodeRune(buf, rune)
strList.AppendVector(child.buildMembers(prefix + string(buf[0:numChars])))
}
return strList
}
示例4: listFiles
// List the names of all regular files in a given directory.
func listFiles(fname string) *vector.StringVector {
files := new(vector.StringVector)
f, _ := os.Open(fname)
dn, _ := f.Readdirnames(-1)
for _, filename := range dn {
if filename[0] == '.' {
continue
}
filename = path.Join(fname, filename)
info, err := os.Stat(filename)
if err != nil {
continue
}
if info.IsDirectory() {
files.AppendVector(listFiles(filename))
} else if info.IsRegular() {
files.Push(filename)
}
}
return files
}
示例5: executeCommand
// executeCommand runs the specified tool with the supplied arguments (not
// including the path to the tool itself), chdir'ing to the specified directory
// first. It returns true if and only if the child process returns zero.
func executeCommand(tool string, args []string, dir string) bool {
fmt.Printf("%s %s\n", tool, strings.Join(args, " "))
var fullArgs vector.StringVector
fullArgs.Push(tool)
fullArgs.AppendVector(&args)
pid, err := os.ForkExec(
tool,
fullArgs.Data(),
os.Environ(),
dir,
[]*os.File{os.Stdin, os.Stdout, os.Stderr})
if err != nil {
panic(err)
}
waitMsg, err := os.Wait(pid, 0)
if err != nil {
panic(err)
}
return waitMsg.ExitStatus() == 0
}
示例6: TestMultiFindValue
func TestMultiFindValue(t *testing.T) {
trie := NewTrie()
// these are part of the matches for the word 'hyphenation'
trie.AddPatternString(`hy3ph`)
trie.AddPatternString(`he2n`)
trie.AddPatternString(`hena4`)
trie.AddPatternString(`hen5at`)
v1 := &vector.IntVector{0, 3, 0, 0}
v2 := &vector.IntVector{0, 2, 0}
v3 := &vector.IntVector{0, 0, 0, 4}
v4 := &vector.IntVector{0, 0, 5, 0, 0}
expectStr := new(vector.StringVector)
expectVal := new(vector.Vector) // contains elements of type *vector.IntVector
expectStr.Push(`hyph`)
expectVal.Push(v1)
found, values := trie.AllSubstringsAndValues(`hyphenation`)
if found.Len() != expectStr.Len() {
t.Errorf("expected %v but found %v", *expectStr, *found)
}
if values.Len() != expectVal.Len() {
t.Errorf("Length mismatch: expected %v but found %v", *expectVal, *values)
}
for i := 0; i < found.Len(); i++ {
if found.At(i) != expectStr.At(i) {
t.Errorf("Strings content mismatch: expected %v but found %v", *expectStr, *found)
break
}
}
for i := 0; i < values.Len(); i++ {
ev := expectVal.At(i).(*vector.IntVector)
fv := values.At(i).(*vector.IntVector)
if ev.Len() != fv.Len() {
t.Errorf("Value length mismatch: expected %v but found %v", *ev, *fv)
break
}
for i := 0; i < ev.Len(); i++ {
if ev.At(i) != fv.At(i) {
t.Errorf("Value mismatch: expected %v but found %v", *ev, *fv)
break
}
}
}
expectStr.Cut(0, expectStr.Len())
expectVal.Cut(0, expectVal.Len())
expectStr.AppendVector(&vector.StringVector{`hen`, `hena`, `henat`})
expectVal.Push(v2)
expectVal.Push(v3)
expectVal.Push(v4)
found, values = trie.AllSubstringsAndValues(`henation`)
if found.Len() != expectStr.Len() {
t.Errorf("expected %v but found %v", *expectStr, *found)
}
if values.Len() != expectVal.Len() {
t.Errorf("Length mismatch: expected %v but found %v", *expectVal, *values)
}
for i := 0; i < found.Len(); i++ {
if found.At(i) != expectStr.At(i) {
t.Errorf("Strings content mismatch: expected %v but found %v", *expectStr, *found)
break
}
}
for i := 0; i < values.Len(); i++ {
ev := expectVal.At(i).(*vector.IntVector)
fv := values.At(i).(*vector.IntVector)
if ev.Len() != fv.Len() {
t.Errorf("Value length mismatch: expected %v but found %v", *ev, *fv)
break
}
for i := 0; i < ev.Len(); i++ {
if ev.At(i) != fv.At(i) {
t.Errorf("Value mismatch: expected %v but found %v", *ev, *fv)
break
}
}
}
}