Compare modules and groups using the

Introduced properties

private var _maxs: HashMap[MGroup, nullable MModule]

nitc :: LinexComparator :: _maxs

private var _mins: HashMap[MGroup, nullable MModule]

nitc :: LinexComparator :: _mins

private fun maxi(o: Object): nullable MModule

nitc :: LinexComparator :: maxi

private fun maxs: HashMap[MGroup, nullable MModule]

nitc :: LinexComparator :: maxs

private fun maxs=(maxs: HashMap[MGroup, nullable MModule])

nitc :: LinexComparator :: maxs=

private fun mini(o: Object): nullable MModule

nitc :: LinexComparator :: mini

private fun mins: HashMap[MGroup, nullable MModule]

nitc :: LinexComparator :: mins

private fun mins=(mins: HashMap[MGroup, nullable MModule])

nitc :: LinexComparator :: mins=

private fun tree=(tree: OrderedTree[MConcern])

nitc :: LinexComparator :: tree=

Redefined properties

redef type COMPARED: MConcern

nitc $ LinexComparator :: COMPARED

What to compare to
redef type SELF: LinexComparator

nitc $ LinexComparator :: SELF

Type of this instance, automatically specialized in every class
redef fun compare(a: COMPARED, b: COMPARED): Int

nitc $ LinexComparator :: compare

Compare a and b.

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type COMPARED: nullable Object

core :: Comparator :: COMPARED

What to compare to
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _maxs: HashMap[MGroup, nullable MModule]

nitc :: LinexComparator :: _maxs

private var _mins: HashMap[MGroup, nullable MModule]

nitc :: LinexComparator :: _mins

fun bubble_sort(array: Array[COMPARED], from: Int, to: Int)

core :: Comparator :: bubble_sort

Bubble-sort array between from and to indices
private fun build_heap(array: Array[COMPARED]): Int

core :: Comparator :: build_heap

protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
abstract fun compare(a: COMPARED, b: COMPARED): Int

core :: Comparator :: compare

Compare a and b.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun heap_sort(array: Array[COMPARED], from: Int, to: Int)

core :: Comparator :: heap_sort

Heap-sort array between from and to indices
private fun heapify(array: Array[COMPARED], from: Int, to: Int)

core :: Comparator :: heapify

init init

core :: Object :: init

fun insertion_sort(array: Array[COMPARED], from: Int, to: Int)

core :: Comparator :: insertion_sort

Insertion-sort array between from and to indices
fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun is_sorted(seq: SequenceRead[COMPARED]): Bool

core :: Comparator :: is_sorted

Is seq sorted?
fun max(a: COMPARED, b: COMPARED): COMPARED

core :: Comparator :: max

Returns the maximum between a and b.
private fun maxi(o: Object): nullable MModule

nitc :: LinexComparator :: maxi

private fun maxs: HashMap[MGroup, nullable MModule]

nitc :: LinexComparator :: maxs

private fun maxs=(maxs: HashMap[MGroup, nullable MModule])

nitc :: LinexComparator :: maxs=

private fun merge(array: Array[COMPARED], from: Int, mid: Int, to: Int)

core :: Comparator :: merge

fun merge_sort(array: Array[COMPARED], from: Int, to: Int)

core :: Comparator :: merge_sort

Merge-sort array between from and to indices
fun min(a: COMPARED, b: COMPARED): COMPARED

core :: Comparator :: min

Returns the minimum between a and b.
private fun mini(o: Object): nullable MModule

nitc :: LinexComparator :: mini

private fun mins: HashMap[MGroup, nullable MModule]

nitc :: LinexComparator :: mins

private fun mins=(mins: HashMap[MGroup, nullable MModule])

nitc :: LinexComparator :: mins=

private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun quick_sort(array: Array[COMPARED], from: Int, to: Int)

core :: Comparator :: quick_sort

Quick-sort array between from and to indices
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun sort(array: Array[COMPARED])

core :: Comparator :: sort

Sort array using the compare function.
private fun sub_sort(array: Array[COMPARED], from: Int, to: Int)

core :: Comparator :: sub_sort

Sort array between from and to indices
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
private fun tree=(tree: OrderedTree[MConcern])

nitc :: LinexComparator :: tree=

package_diagram nitc::model_viz::LinexComparator LinexComparator core::Comparator Comparator nitc::model_viz::LinexComparator->core::Comparator core::Object Object core::Comparator->core::Object ...core::Object ... ...core::Object->core::Object

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

interface Comparator

core :: Comparator

This abstract class generalizes ways to sort an array

Class definitions

nitc $ LinexComparator
# 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