本文整理汇总了Golang中container/vector.Vector.AppendVector方法的典型用法代码示例。如果您正苦于以下问题:Golang Vector.AppendVector方法的具体用法?Golang Vector.AppendVector怎么用?Golang Vector.AppendVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类container/vector.Vector
的用法示例。
在下文中一共展示了Vector.AppendVector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ContainsExactly
// The actual collection must contain all expected elements and nothing else.
// The order of elements is not significant.
func ContainsExactly(actual_ interface{}, expected_ interface{}) (match bool, pos Message, neg Message, err os.Error) {
actual, err := toArray(actual_)
if err != nil {
return
}
expected, err := toArray(expected_)
if err != nil {
return
}
containsAll := true
remaining := new(vector.Vector)
remaining.AppendVector((*vector.Vector)(&actual))
for i := 0; i < len(expected); i++ {
if idx, found := findIndex(*remaining, expected[i]); found {
remaining.Delete(idx)
} else {
containsAll = false
break
}
}
match = containsAll && remaining.Len() == 0
pos = Messagef(actual, "contains exactly “%v”", expected)
neg = Messagef(actual, "does NOT contain exactly “%v”", expected)
return
}
示例2: Parse
//.........这里部分代码省略.........
case 'g': // signature
size, e := _GetByte(buff, bufIdx)
if e != nil {
err = e
return
}
str, e := _GetString(buff, bufIdx+1, int(size))
if e != nil {
err = e
return
}
vec.Push(str)
bufIdx += (1 + int(size) + 1)
sigIdx++
case 'a': // array
startIdx := _Align(4, bufIdx)
arySize, e := _GetInt32(buff, startIdx)
if e != nil {
err = e
return
}
sigBlock, e := _GetSigBlock(sig, sigIdx+1)
if e != nil {
err = e
return
}
aryIdx := startIdx + 4
aryVec := new(vector.Vector)
for aryIdx < (startIdx+4)+int(arySize) {
retvec, retidx, e := Parse(buff, sigBlock, aryIdx)
if e != nil {
err = e
return
}
aryVec.AppendVector(retvec)
aryIdx = retidx
}
bufIdx = aryIdx
sigIdx += (1 + len(sigBlock))
vec.Push(aryVec)
case '(': // struct
idx := _Align(8, bufIdx)
stSig, e := _GetStructSig(sig, sigIdx)
if e != nil {
err = e
return
}
retvec, retidx, e := Parse(buff, stSig, idx)
if e != nil {
err = e
return
}
bufIdx = retidx
sigIdx += (len(stSig) + 2)
vec.Push(retvec)
case '{': // dict
idx := _Align(8, bufIdx)
stSig, e := _GetDictSig(sig, sigIdx)
if e != nil {
err = e
return
}
retvec, retidx, e := Parse(buff, stSig, idx)
if e != nil {
err = e
return
}
bufIdx = retidx
sigIdx += (len(stSig) + 2)
vec.Push(retvec)
case 'v': // variant
val, idx, e := _GetVariant(buff, bufIdx)
if e != nil {
err = e
return
}
bufIdx = idx
sigIdx++
vec.AppendVector(val)
default:
fmt.Println(sig[sigIdx])
return nil, index, os.NewError("unknown type")
}
}
return
}
示例3: AppendToVector
//append a sequence to a vector
func AppendToVector(vec *vector.Vector, s Seq) {
switch arg := s.(type) {
case *SequentialSeq: vec.AppendVector((*vector.Vector)(arg))
default: Do(s, func(el El){vec.Push(el)})
}
}