Returns a mask composed by discriminants bits

for these given identifiers The mask + 1 value is the size of the hastable to create

Property definitions

perfect_hashing $ Perfecthashing :: phand
	# Returns a mask composed by discriminants bits
	# for these given identifiers
	# The mask + 1 value is the size of the hastable to create
	fun phand(ids: Array[Int]): Int
	do
		var mask = 1

		# If ids is null return 1
		if ids.length == 0 then
			return mask
		end

		var orMask = 0
		var andMask = 0
		for i in ids do
			orMask |= i
			andMask &= i
		end

		mask = orMask ^ andMask

		# Re-initialize the hashtable with null values
		for i in [0..(mask+1)] do tempht[i] = null

		# Optimize the already computed mask
		var newmask = 0
		var i = mask.highest_bit
		while i != 0 do
			if mask.getbit(i) == 1 then
				newmask = mask ^ (1 << i)

				# If there is no collision, replace the old mask
				if phandp(ids, newmask) then
					mask = newmask
				end
			end

			i -= 1
		end

		return mask + 1
	end
lib/perfect_hashing/perfect_hashing.nit:40,2--81,4