本文整理匯總了Golang中github.com/google/cayley/graph.Iterator.FixedTags方法的典型用法代碼示例。如果您正苦於以下問題:Golang Iterator.FixedTags方法的具體用法?Golang Iterator.FixedTags怎麽用?Golang Iterator.FixedTags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/cayley/graph.Iterator
的用法示例。
在下文中一共展示了Iterator.FixedTags方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CopyTagsFrom
func (it *Base) CopyTagsFrom(other_it graph.Iterator) {
for _, tag := range other_it.Tags() {
it.AddTag(tag)
}
for k, v := range other_it.FixedTags() {
it.AddFixedTag(k, v)
}
}
示例2: MakeNode
func (qs *queryShape) MakeNode(it graph.Iterator) *Node {
n := Node{Id: qs.nodeId}
for _, tag := range it.Tags() {
n.Tags = append(n.Tags, tag)
}
for k, _ := range it.FixedTags() {
n.Tags = append(n.Tags, k)
}
switch it.Type() {
case graph.And:
for _, sub := range it.SubIterators() {
qs.nodeId++
newNode := qs.MakeNode(sub)
if sub.Type() != graph.Or {
qs.StealNode(&n, newNode)
} else {
qs.AddNode(newNode)
qs.AddLink(&Link{n.Id, newNode.Id, 0, 0})
}
}
case graph.Fixed:
n.IsFixed = true
for {
val, more := it.Next()
if !more {
break
}
n.Values = append(n.Values, qs.ts.NameOf(val))
}
case graph.HasA:
hasa := it.(*HasA)
qs.PushHasa(n.Id, hasa.dir)
qs.nodeId++
newNode := qs.MakeNode(hasa.primaryIt)
qs.AddNode(newNode)
qs.RemoveHasa()
case graph.Or:
for _, sub := range it.SubIterators() {
qs.nodeId++
newNode := qs.MakeNode(sub)
if sub.Type() == graph.Or {
qs.StealNode(&n, newNode)
} else {
qs.AddNode(newNode)
qs.AddLink(&Link{n.Id, newNode.Id, 0, 0})
}
}
case graph.LinksTo:
n.IsLinkNode = true
lto := it.(*LinksTo)
qs.nodeId++
newNode := qs.MakeNode(lto.primaryIt)
hasaID, hasaDir := qs.LastHasa()
if (hasaDir == graph.Subject && lto.dir == graph.Object) ||
(hasaDir == graph.Object && lto.dir == graph.Subject) {
qs.AddNode(newNode)
if hasaDir == graph.Subject {
qs.AddLink(&Link{hasaID, newNode.Id, 0, n.Id})
} else {
qs.AddLink(&Link{newNode.Id, hasaID, 0, n.Id})
}
} else if lto.primaryIt.Type() == graph.Fixed {
qs.StealNode(&n, newNode)
} else {
qs.AddNode(newNode)
}
case graph.Optional:
// Unsupported, for the moment
fallthrough
case graph.All:
}
return &n
}