本文整理汇总了Golang中github.com/attic-labs/noms/go/types.Set类的典型用法代码示例。如果您正苦于以下问题:Golang Set类的具体用法?Golang Set怎么用?Golang Set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Set类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: commitRefsFromSet
func commitRefsFromSet(set types.Set) []types.Ref {
res := []types.Ref{}
set.IterAll(func(v types.Value) {
res = append(res, v.(types.Ref))
})
return res
}
开发者ID:Richardphp,项目名称:noms,代码行数:7,代码来源:commit_iterator.go
示例2: diffSets
func diffSets(w io.Writer, p types.Path, v1, v2 types.Set) {
changeChan := make(chan types.ValueChanged)
stopChan := make(chan struct{}, 1) // buffer size of 1, so this won't block if diff already finished
defer stop(stopChan)
go func() {
v2.Diff(v1, changeChan, stopChan)
close(changeChan)
}()
wroteHeader := false
for change := range changeChan {
wroteHeader = writeHeader(w, wroteHeader, p)
switch change.ChangeType {
case types.DiffChangeAdded:
line(w, ADD, nil, change.V)
case types.DiffChangeRemoved:
line(w, DEL, nil, change.V)
default:
panic("unknown change type")
}
}
writeFooter(w, wroteHeader)
}
开发者ID:kalman,项目名称:noms-pre-release,代码行数:26,代码来源:diff.go
示例3: diffSets
func diffSets(w io.Writer, p types.Path, v1, v2 types.Set) error {
return diffOrdered(w, p, line, func(cc chan<- types.ValueChanged, sc <-chan struct{}) {
v2.DiffLeftRight(v1, cc, sc)
},
func(k types.Value) types.Value { return nil },
func(k types.Value) types.Value { return k },
func(k types.Value) types.Value { return k },
)
}
开发者ID:Richardphp,项目名称:noms,代码行数:9,代码来源:diff.go
示例4: getAncestors
func getAncestors(commits types.Set, vr types.ValueReader) types.Set {
ancestors := types.NewSet()
commits.IterAll(func(v types.Value) {
r := v.(types.Ref)
c := r.TargetValue(vr).(types.Struct)
next := []types.Value{}
c.Get(ParentsField).(types.Set).IterAll(func(v types.Value) {
next = append(next, v)
})
ancestors = ancestors.Insert(next...)
})
return ancestors
}
开发者ID:willhite,项目名称:noms-old,代码行数:13,代码来源:database_common.go
示例5: valueTypesFromParents
func valueTypesFromParents(parents types.Set, fieldName string) []*types.Type {
elemType := getSetElementType(parents.Type())
switch elemType.Kind() {
case types.UnionKind:
ts := []*types.Type{}
for _, rt := range elemType.Desc.(types.CompoundDesc).ElemTypes {
ts = append(ts, fieldTypeFromRefOfCommit(rt, fieldName))
}
return ts
default:
return []*types.Type{fieldTypeFromRefOfCommit(elemType, fieldName)}
}
}
开发者ID:Richardphp,项目名称:noms,代码行数:13,代码来源:commit.go
示例6: diffSets
func diffSets(dq *diffQueue, w io.Writer, p types.Path, v1, v2 types.Set) {
wroteHeader := false
added, removed := v2.Diff(v1)
if len(added) == 1 && len(removed) == 1 && canCompare(added[0], removed[0]) {
p1 := p.AddField(added[0].Hash().String())
dq.PushBack(diffInfo{path: p1, key: types.String(""), v1: removed[0], v2: added[0]})
} else {
for _, value := range removed {
wroteHeader = writeHeader(w, wroteHeader, p)
line(w, subPrefix, nil, value)
}
for _, value := range added {
wroteHeader = writeHeader(w, wroteHeader, p)
line(w, addPrefix, nil, value)
}
}
writeFooter(w, wroteHeader)
return
}
开发者ID:willhite,项目名称:noms-old,代码行数:19,代码来源:diff.go
示例7: diffSummarySet
func diffSummarySet(ch chan<- diffSummaryProgress, v1, v2 types.Set) {
diffSummaryValueChanged(ch, v1.Len(), v2.Len(), func(changeChan chan<- types.ValueChanged, stopChan <-chan struct{}) {
v2.Diff(v1, changeChan, stopChan)
})
}
开发者ID:kalman,项目名称:noms-pre-release,代码行数:5,代码来源:summary.go
注:本文中的github.com/attic-labs/noms/go/types.Set类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论