本文整理汇总了Golang中github.com/couchbaselabs/sync_gateway/base.Set.Contains方法的典型用法代码示例。如果您正苦于以下问题:Golang Set.Contains方法的具体用法?Golang Set.Contains怎么用?Golang Set.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbaselabs/sync_gateway/base.Set
的用法示例。
在下文中一共展示了Set.Contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: updateChannels
// Updates the Channels property of a document object with current & past channels.
// Returns the set of channels that have changed (document joined or left in this revision)
func (doc *document) updateChannels(newChannels base.Set) (changedChannels base.Set) {
var changed []string
oldChannels := doc.Channels
if oldChannels == nil {
oldChannels = ChannelMap{}
doc.Channels = oldChannels
} else {
// Mark every no-longer-current channel as unsubscribed:
curSequence := doc.Sequence
for channel, removal := range oldChannels {
if removal == nil && !newChannels.Contains(channel) {
oldChannels[channel] = &ChannelRemoval{
Seq: curSequence,
RevID: doc.CurrentRev,
Deleted: doc.Deleted}
changed = append(changed, channel)
}
}
}
// Mark every current channel as subscribed:
for channel, _ := range newChannels {
if value, exists := oldChannels[channel]; value != nil || !exists {
oldChannels[channel] = nil
changed = append(changed, channel)
}
}
if changed != nil {
base.LogTo("CRUD", "\tDoc %q in channels %q", doc.ID, newChannels)
changedChannels = channels.SetOf(changed...)
}
return
}
示例2: UpdateAtSequence
// Updates membership to match the given Set. Newly added members will have the given sequence.
func (set TimedSet) UpdateAtSequence(other base.Set, sequence uint64) bool {
changed := false
for name, _ := range set {
if !other.Contains(name) {
delete(set, name)
changed = true
}
}
for name, _ := range other {
if !set.Contains(name) {
set[name] = sequence
changed = true
}
}
return changed
}
示例3: ExpandWildCardChannel
// If a channel list contains a wildcard ("*"), replace it with all the user's accessible channels.
func (user *userImpl) ExpandWildCardChannel(channels base.Set) base.Set {
if channels.Contains("*") {
channels = user.InheritedChannels().AsSet()
}
return channels
}