package font

// Code generated by typesetting-utils/generators/cache/gen.go. DO NOT EDIT.

/* Implements caches for integers key->value functions.
 *
 * The cache is a fixed-size array of 8-bit, 16-bit or 32-bit integers,
 * typically 256 elements.
 *
 * The key is split into two parts: the cache index (high bits)
 * and the rest (low bits).
 *
 * The memory layout is the following :
 * 	KEY 		= <key bits - cache bits><cache bits>
 * 	VALUE 	= <key bits - cache bits><value bits>
 * with the constraints
 *	KEY in [0, 2^key bits[
 *	VALUE in [0, 2^value bits[
 *
 * The cache index is used to index into the array. The array
 * member is an integer that is used BOTH
 * to store the low bits of the key, and the value.
 *
 * The value is stored in the least significant bits of the integer.
 * The low bits of the key are stored in the most significant bits
 * of the integer.
 *
 * A cache hit is detected by comparing the low bits of the key
 * with the high bits of the integer at the array position indexed
 * by the high bits of the key. If they match, the value is extracted
 * from the least significant bits of the integer and returned.
 * Otherwise, a cache miss is reported.
 *
 * Cache operations (storage and retrieval) involve just a few
 * arithmetic operations and a single memory access.
 */

// cache21_19_8 is a cache for integer (key, value) pairs,
// with 0 <= key < 2097152 and 0 <= value < 524288
type cache21_19_8 [1 << 8]uint32

// clear should be used as init function
func ( *cache21_19_8) () {
	for  := range  {
		[] = ^uint32(0)
	}
}

func ( cache21_19_8) ( uint32) (uint32, bool) {
	 :=  & ((1 << 8) - 1)
	 := []
	if  == ^uint32(0) || (>>19) != uint32(>>8) {
		return 0, false
	}
	return  & ((1 << 19) - 1), true
}

func ( *cache21_19_8) ( uint32,  uint32) {
	if (>>21) != 0 || (>>19) != 0 { /* overflows */
		return
	}
	.setUnchecked(, )
}

// assumes key < 2097152 and value < 524288
func ( *cache21_19_8) ( uint32,  uint32) {
	 :=  & ((1 << 8) - 1)
	 := (uint32(>>8) << 19) | 
	[] = 
}