Register a candidate with a distance

  • To high, it is ignored.
  • Equal to the current best, it is added
  • Better that them, is is the new best element

Return true if the candidate is kept (alone or with other) returns false if the candidate is ignored.

Property definitions

more_collections $ BestDistance :: update
	# Register a `candidate` with a `distance`
	#
	# * To high, it is ignored.
	# * Equal to the current best, it is added
	# * Better that them, is is the new best element
	#
	# Return `true` if the candidate is kept (alone or with other)
	# returns `false` if the candidate is ignored.
	fun update(distance: Int, candidate: E): Bool
	do
		if distance > best_distance then return false
		if distance < best_distance then
			best_distance = distance
			best_items.clear
		end
		best_items.add candidate
		return true
	end
lib/more_collections/more_collections.nit:701,2--718,4