code: func (c *Container) check() error {
  	var a ErrorList
  
  	if c.isArray() {
  		array := c.array()
  		if int32(len(array)) != c.n {
  			a.Append(fmt.Errorf("array count mismatch: count=%d, n=%d", len(array), c.n))
  		}
  	} else if c.isRun() {
  		n := c.runCountRange(0, maxContainerVal+1)
  		if n != c.n {
  			a.Append(fmt.Errorf("run count mismatch: count=%d, n=%d", n, c.n))
  		}
  	} else if c.isBitmap() {
  		if n := c.bitmapCountRange(0, maxContainerVal+1); n != c.n {
  			a.Append(fmt.Errorf("bitmap count mismatch: count=%d, n=%d", n, c.n))
  		}
  	} else {
  		a.Append(fmt.Errorf("empty container"))
  		if c.n != 0 {
  			a.Append(fmt.Errorf("empty container with nonzero count: n=%d", c.n))
  		}
  	}
  
  	if a == nil {
  		return nil
  	}
  	return a
  }
docs: // check performs a consistency check on the container.