func (me *PriorityBitmap) Set(bit int, priority int) { me.deleteBit(bit) if me.priorities == nil { me.priorities = make(map[int]int) } me.priorities[bit] = priority if me.om == nil { me.om = orderedmap.New(bitLess) } _v, ok := me.om.GetOk(priority) if !ok { me.om.Set(priority, bit) return } switch v := _v.(type) { case int: newV := bitSets.Get().(map[int]struct{}) newV[v] = struct{}{} newV[bit] = struct{}{} me.om.Set(priority, newV) case map[int]struct{}: v[bit] = struct{}{} } }
func (me *PriorityBitmap) lazyInit() { me.om = orderedmap.New(func(l, r interface{}) bool { return l.(int) < r.(int) }) me.priorities = make(map[int]int) }