package ecs

import (
	
)

// maskTotalBits is the size of a [bitMask] in bits.
// It is the maximum number of component types that may exist in any [World].
const mask64TotalBits = 64

// bitMask is a 64 bit bit-mask.
type bitMask64 struct {
	bits uint64 // 64 bits of the mask
}

// newMask creates a new Mask from a list of IDs.
// Matches all entities that have the respective components, and potentially further components.
func newMask64( ...ID) bitMask64 {
	var  bitMask64
	for ,  := range  {
		.Set(.id)
	}
	return 
}

// Get reports whether the bit at the given index [ID] is set.
func ( *bitMask64) ( uint8) bool {
	 := uint64(1 << )
	return .bits& == 
}

// Set sets the state of the bit at the given index.
func ( *bitMask64) ( uint8) {
	.bits |= (1 << )
}

// Clear sets the state of the bit at the given index.
func ( *bitMask64) ( uint8) {
	.bits &= ^(1 << )
}

// Not returns the inversion of this mask.
func ( *bitMask64) () bitMask64 {
	return bitMask64{
		bits: ^.bits,
	}
}

// OrI calculates the OR of this mask and other in-place.
func ( *bitMask64) ( *bitMask64) {
	.bits |= .bits
}

// IsZero returns whether no bits are set in the mask.
func ( *bitMask64) () bool {
	return .bits == 0
}

// Reset the mask setting all bits to false.
func ( *bitMask64) () {
	.bits = 0
}

// Contains reports if the other mask is a subset of this mask.
func ( *bitMask64) ( *bitMask64) bool {
	return .bits&.bits == .bits
}

// ContainsAny reports if any bit of the other mask is in this mask.
func ( *bitMask64) ( *bitMask64) bool {
	return .bits&.bits != 0
}

// TotalBitsSet returns how many bits are set in this mask.
func ( *bitMask64) () int {
	return bits.OnesCount64(.bits)
}

// Equals returns whether two masks are equal.
func ( *bitMask64) ( *bitMask64) bool {
	return .bits == .bits
}

// toTypes converts a mask to a list of component IDs.
func ( *bitMask64) ( *registry) []ID {
	if .bits == 0 {
		return nil
	}

	 := .TotalBitsSet()
	 := make([]ID, )
	 := .Count()

	 := 0
	for  := range  {
		 := ID{id: uint8()}
		if .Get(.id) {
			[] = 
			++
		}
	}
	return 
}