當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Set.Contains方法代碼示例

本文整理匯總了Golang中github.com/couchbase/sync_gateway/base.Set.Contains方法的典型用法代碼示例。如果您正苦於以下問題:Golang Set.Contains方法的具體用法?Golang Set.Contains怎麽用?Golang Set.Contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/couchbase/sync_gateway/base.Set的用法示例。


在下文中一共展示了Set.Contains方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 = channels.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] = &channels.ChannelRemoval{
					Seq:     curSequence,
					RevID:   doc.CurrentRev,
					Deleted: doc.hasFlag(channels.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:guoyu07,項目名稱:sync_gateway,代碼行數:35,代碼來源:document.go

示例2: Equals

// Check for matching entry names, ignoring sequence
func (set TimedSet) Equals(other base.Set) bool {

	for name, _ := range set {
		if !other.Contains(name) {
			return false
		}
	}
	for name, _ := range other {
		if !set.Contains(name) {
			return false
		}
	}
	return true
}
開發者ID:joeljeske,項目名稱:sync_gateway,代碼行數:15,代碼來源:timed_set.go

示例3: 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] = NewVbSimpleSequence(sequence)
			changed = true
		}
	}
	return changed
}
開發者ID:joeljeske,項目名稱:sync_gateway,代碼行數:17,代碼來源:timed_set.go

示例4: ExpandWildCardChannel

// If a channel list contains the all-channel wildcard, replace it with all the user's accessible channels.
func (user *userImpl) ExpandWildCardChannel(channels base.Set) base.Set {
	if channels.Contains(ch.AllChannelWildcard) {
		channels = user.InheritedChannels().AsSet()
	}
	return channels
}
開發者ID:guoyu07,項目名稱:sync_gateway,代碼行數:7,代碼來源:user.go


注:本文中的github.com/couchbase/sync_gateway/base.Set.Contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。