func (c *Set) ClearFlag(vec Flag) error {
	return c.forceFlag(vec, false)
}
ClearFlag clears a specific vector of Values associated with the
specified Flag.
package cap
import "errors"
func (c *Set) GetFlag(vec Flag, val Value) (bool, error) {
	if c == nil || len(c.flat) == 0 {
		return false, ErrBadSet
	}
	offset, mask, err := bitOf(vec, val)
	if err != nil {
		return false, err
	}
	c.mu.RLock()
	defer c.mu.RUnlock()
	return c.flat[offset][vec]&mask != 0, nil
}
func (c *Set) SetFlag(vec Flag, enable bool, val ...Value) error {
	if c == nil || len(c.flat) == 0 {
		return ErrBadSet
	}
	c.mu.Lock()
	defer c.mu.Unlock()
	replace := make([]uint32, words)
	for i := range replace {
		replace[i] = c.flat[i][vec]
	}
	var err error
	for _, v := range val {
		offset, mask, err2 := bitOf(vec, v)
		if err2 != nil {
			err = err2
			break
		}
		if enable {
			c.flat[offset][vec] |= mask
		} else {
			c.flat[offset][vec] &= ^mask
		}
	}
	if err == nil {
		return nil
	}
	for i, bits := range replace {
		c.flat[i][vec] = bits
	}
	return err
}
func (c *Set) Clear() error {
	if c == nil || len(c.flat) == 0 {
		return ErrBadSet
	}
	c.mu.Lock()
	defer c.mu.Unlock()
	c.flat = make([]data, words)
	c.nsRoot = 0
	return nil
}
var ErrBadValue = errors.New("bad capability value")
func bitOf(vec Flag, val Value) (uint, uint32, error) {
	if vec > Inheritable || val > Value(words*32) {
		return 0, 0, ErrBadValue
	}
	u := uint(val)
	return u / 32, uint32(1) << (u % 32), nil
}
func allMask(index uint) (mask uint32) {
	if maxValues == 0 {
		panic("uninitialized package")
	}
	base := 32 * uint(index)
	if maxValues <= base {
		return
	}
	if maxValues >= 32+base {
		mask = ^mask
		return
	}
	mask = uint32((uint64(1) << (maxValues % 32)) - 1)
	return
}
func (c *Set) forceFlag(vec Flag, enable bool) error {
	if c == nil || len(c.flat) == 0 || vec > Inheritable {
		return ErrBadSet
	}
	m := uint32(0)
	if enable {
		m = ^m
	}
	c.mu.Lock()
	defer c.mu.Unlock()
	for i := range c.flat {
		c.flat[i][vec] = m & allMask(uint(i))
	}
	return nil
}