package rendezvous

type Rendezvous struct {
	nodes map[string]int
	nstr  []string
	nhash []uint64
	hash  Hasher
}

type Hasher func(s string) uint64

func ( []string,  Hasher) *Rendezvous {
	 := &Rendezvous{
		nodes: make(map[string]int, len()),
		nstr:  make([]string, len()),
		nhash: make([]uint64, len()),
		hash:  ,
	}

	for ,  := range  {
		.nodes[] = 
		.nstr[] = 
		.nhash[] = ()
	}

	return 
}

short-circuit if we're empty
	if len(.nodes) == 0 {
		return ""
	}

	 := .hash()

	var  int
	var  = xorshiftMult64( ^ .nhash[0])

	for ,  := range .nhash[1:] {
		if  := xorshiftMult64( ^ );  >  {
			 =  + 1
			 = 
		}
	}

	return .nstr[]
}

func ( *Rendezvous) ( string) {
	.nodes[] = len(.nstr)
	.nstr = append(.nstr, )
	.nhash = append(.nhash, .hash())
}

find index of node to remove
	 := .nodes[]
remove from the slices
	 := len(.nstr)
	.nstr[] = .nstr[]
	.nstr = .nstr[:]

	.nhash[] = .nhash[]
	.nhash = .nhash[:]
update the map
	delete(.nodes, )
	 := .nstr[]
	.nodes[] = 
}

func ( uint64) uint64 {
	 ^=  >> 12 // a
	 ^=  << 25 // b
	 ^=  >> 27 // c
	return  * 2685821657736338717