示例#1
0
func treemapInsert(theMap *treemap.Map, key int64, target string) {
	value, _ := theMap.Get(key)
	var entry []string
	if value == nil {
		entry = []string{target}
	} else {
		entry = value.([]string)
		entry = append(entry, target)
	}
	theMap.Put(key, entry)
}
示例#2
0
func treemapRemove(theMap *treemap.Map, key int64, target string) {
	value, _ := theMap.Get(key)
	if value == nil {
		cacheLogger.Error("Could not find element in treemap")
		return
	}
	entry := value.([]string)
	foundIndex := -1
	for index, targetJ := range entry {
		if target == targetJ {
			foundIndex = index
			break
		}
	}
	if foundIndex == -1 {
		cacheLogger.Error("Could not find element in treemap")
		return
	}
	entry = append(entry[:foundIndex], entry[foundIndex+1:]...)
	theMap.Put(key, entry)
}