Esempio n. 1
0
// HashMapExample to demonstrate basic usage of HashMap
func HashMapExample() {
	m := hashmap.New() // empty
	m.Put(1, "x")      // 1->x
	m.Put(2, "b")      // 2->b, 1->x  (random order)
	m.Put(1, "a")      // 2->b, 1->a (random order)
	_, _ = m.Get(2)    // b, true
	_, _ = m.Get(3)    // nil, false
	_ = m.Values()     // []interface {}{"b", "a"} (random order)
	_ = m.Keys()       // []interface {}{1, 2} (random order)
	m.Remove(1)        // 2->b
	m.Clear()          // empty
	m.Empty()          // true
	m.Size()           // 0
}
Esempio n. 2
0
// New instantiates a bidirectional map.
func New() *Map {
	return &Map{*hashmap.New(), *hashmap.New()}
}
Esempio n. 3
0
// utils
package utils

import (
	"bufio"
	"github.com/emirpasic/gods/maps/hashmap"
	"github.com/emirpasic/gods/sets/hashset"
	"io"
	"os"
	"strconv"
	"strings"
)

//var slavers1 []string
var healthslaveAndtask *hashmap.Map = hashmap.New() //key是主机,value是任务
var healthtaskAndslave *hashmap.Map = hashmap.New() //key是主机,value是任务
var healthSlaversSet *hashset.Set = hashset.New()   //可以分配任务的从节点列表
var livedSlaverSet *hashset.Set = hashset.New()     //活着的从节点列表
func AddhealthSlavers(slaver string) {
	healthSlaversSet.Add(slaver)
}
func GethealthSlavers() *hashset.Set {
	return healthSlaversSet
}
func SethealthSlavers(slavers *hashset.Set) {
	healthSlaversSet = slavers
}
func RemhealthSlaver(slave string) {
	healthSlaversSet.Remove(slave)
}
func AddlivedSlavers(slaver string) {