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


Golang StringMap.Clone方法代码示例

本文整理汇总了Golang中github.com/cgrates/cgrates/utils.StringMap.Clone方法的典型用法代码示例。如果您正苦于以下问题:Golang StringMap.Clone方法的具体用法?Golang StringMap.Clone怎么用?Golang StringMap.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cgrates/cgrates/utils.StringMap的用法示例。


在下文中一共展示了StringMap.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: getSessionIDsMatchingIndexes

// getSessionIDsMatchingIndexes will check inside indexes if it can find sessionIDs matching all filters
// matchedIndexes returns map[matchedFieldName]possibleMatchedFieldVal so we optimize further to avoid checking them
func (smg *SMGeneric) getSessionIDsMatchingIndexes(fltrs map[string]string) (utils.StringMap, map[string]string) {
	smg.aSIMux.RLock()
	defer smg.aSIMux.RUnlock()
	sessionIDxes := smg.aSessionsIndex // Clone here and unlock sooner if getting slow
	matchedIndexes := make(map[string]string)
	var matchingSessions utils.StringMap
	checkNr := 0
	for fltrName, fltrVal := range fltrs {
		checkNr += 1
		if _, hasFldName := sessionIDxes[fltrName]; !hasFldName {
			continue
		}
		if _, hasFldVal := sessionIDxes[fltrName][fltrVal]; !hasFldVal {
			matchedIndexes[fltrName] = utils.META_NONE
			continue
		}
		matchedIndexes[fltrName] = fltrVal
		if checkNr == 1 { // First run will init the MatchingSessions
			matchingSessions = sessionIDxes[fltrName][fltrVal]
			continue
		}
		// Higher run, takes out non matching indexes
		for sessID := range sessionIDxes[fltrName][fltrVal] {
			if _, hasUUID := matchingSessions[sessID]; !hasUUID {
				delete(matchingSessions, sessID)
			}
		}
	}
	return matchingSessions.Clone(), matchedIndexes
}
开发者ID:rinor,项目名称:cgrates,代码行数:32,代码来源:smgeneric.go


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