当前位置: 首页>>代码示例>>Golang>>正文


Golang Set.Contains方法代码示例

本文整理汇总了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
}
开发者ID:phmdb,项目名称:sync_gateway,代码行数:35,代码来源:document.go

示例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
}
开发者ID:nod,项目名称:sync_gateway,代码行数:17,代码来源:timed_set.go

示例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
}
开发者ID:nod,项目名称:sync_gateway,代码行数:7,代码来源:user.go


注:本文中的github.com/couchbaselabs/sync_gateway/base.Set.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。