func (blueset *BlueSetCache) InCache(n *Node) bool {
	blueset.RLock()
	defer blueset.RUnlock()
	return blueset.inCache(n)
}
InCache returns true if the node is in the blueset cache
package phantom
import (
	"fmt"
	"sort"
	"strings"
	"sync"
)
const (
	maxBlueSetCacheSize = 5000
	edgeHorizon = 200
)
type BlueSetCache struct {
	cache map[*Node]*nodeSet
	addsSinceLastExpire int
	sync.RWMutex
}
func NewBlueSetCache() *BlueSetCache {
	return &BlueSetCache {
		cache: make(map[*Node]*nodeSet),
	}
}
func (blueset *BlueSetCache) add(n *Node, set *nodeSet) {
	size := len(blueset.cache)
	if size >= maxBlueSetCacheSize && blueset.addsSinceLastExpire >= cacheFullExpireInterval {
		amt := (size - maxBlueSetCacheSize) + 1
		blueset.expire(amt)
		blueset.addsSinceLastExpire = 0
	}
	blueset.cache[n] = set
	blueset.addsSinceLastExpire += 1
}
func (blueset *BlueSetCache) Add(n *Node, set *nodeSet) {
	blueset.Lock()
	defer blueset.Unlock()
	blueset.add(n, set)
}
func (blueset *BlueSetCache) expire(amt int) {
	if amt <= 0 {
		return
	}
	size := len(blueset.cache)
	if size < amt {
		amt = size
	}
	nodes := make([]*Node, amt)
	index := 0
	for n := range blueset.cache {
		nodes[index] = n
		index += 1
		if index >= amt {
			break
		}
	}
	for _, n := range nodes {
		delete(blueset.cache, n)
	}
}
func (blueset *BlueSetCache) Expire(amt int) {
	blueset.Lock()
	defer blueset.Unlock()
	blueset.expire(amt)
}
func (blueset *BlueSetCache) GetBlueNodes(n *Node) []*Node {
	blueset.RLock()
	defer blueset.RUnlock()
	set, ok := blueset.cache[n]
	if !ok {
		return nil
	}
	return set.elements()
}
func (blueset *BlueSetCache) getBlueSet(n *Node) *nodeSet {
	set, exists := blueset.cache[n]
	if !exists {
		return nil
	}
	return set
}
func (blueset *BlueSetCache) GetBlueSet(n *Node) *nodeSet {
	blueset.RLock()
	defer blueset.RUnlock()
	return blueset.getBlueSet(n)
}
func (blueset *BlueSetCache) inCache(n *Node) bool {
	_, exists := blueset.cache[n]
	return exists
}