Property definitions

nitc $ LinexComparator :: defaultinit
# Compare modules and groups using the
private class LinexComparator
	super Comparator

	redef type COMPARED: MConcern

	var mins = new HashMap [MGroup, nullable MModule]
	var maxs = new HashMap [MGroup, nullable MModule]
	fun mini(o: Object): nullable MModule do
		if o isa MModule then return o
		assert o isa MGroup
		if not mins.has_key(o) then computeminmax(o)
		return mins[o]
	end
	fun maxi(o: Object): nullable MModule do
		if o isa MModule then return o
		assert o isa MGroup
		if not maxs.has_key(o) then computeminmax(o)
		return maxs[o]
	end
	fun computeminmax(o: MGroup) do
		if not tree.sub.has_key(o) then
			mins[o] = null
			maxs[o] = null
			return
		end
		var subs = tree.sub[o]
		var minres = mini(subs.first)
		var maxres = maxi(subs.first)
		var order = o.model.mmodule_importation_hierarchy
		for o2 in subs do
			var c = mini(o2)
			if c == null then continue
			if minres == null or order.compare(minres, c) > 0 then minres = c
			c = maxi(o2)
			if c == null then continue
			if maxres == null or order.compare(maxres, c) < 0 then maxres = c
		end
		mins[o] = minres
		maxs[o] = maxres
		#if minres != maxres then print "* {o} {minres}..{maxres}"
	end
	redef fun compare(a,b) do
		var ma = mini(a)
		var mb = mini(b)
		if ma == null then
			if mb == null then return 0 else return -1
		else if mb == null then
			return 1
		end
		var order = ma.model.mmodule_importation_hierarchy
		return order.compare(ma, mb)
	end
	var tree: OrderedTree[MConcern]
end
src/model/model_viz.nit:59,1--113,3