Automatic generation produced by ISE Eiffel

Classes Clusters Cluster hierarchy Chart Relations Flat contracts Go to:
note description: "[ Topological sorter. Used to produce a total order on a set of elements having only a partial order. ]" author: "Olivier Jeger" license: "Eiffel Forum License v2 (see forum.txt)" date: "$Date: 2020-07-28 04:10:20 -0800 (Tue, 28 Jul 2020) $" revision: "$Revision: 104556 $" eis: "name=Devising and engineering an algorithm: Topological Sort", "src=https://link.springer.com/chapter/10.1007/978-3-540-92145-5_15", "protocol=uri" class interface TOPOLOGICAL_SORTER [G -> HASHABLE] create make -- Create topological sorter. ensure index_of_element_empty: index_of_element.is_empty element_of_index_empty: element_of_index.is_empty successors_empty: successors.is_empty predecessor_count_is_empty: predecessor_count.is_empty cycle_list_impl_empty: cycle_list_impl.is_empty output_empty: output.is_empty fifo_output: fifo_output feature -- Initialization record_constraint (e, f: G) -- Add the constraint [e,f]. require not_sorted: not done not_void: e /= Void and f /= Void record_element (e: G) -- Add e to the set of elements, unless already present. require not_sorted: not done feature -- Access cycle_found: BOOLEAN -- Did the original constraint imply a cycle? require sorted: done cycle_list: LIST [G] -- Elements involved in cycles require sorted: done ensure empty_iff_none: (not cycle_found) = (Result.is_empty) not_empty_if_cycle: cycle_found implies (not Result.is_empty) generating_type: TYPE [detachable TOPOLOGICAL_SORTER [G]] -- Type of current object -- (type of which it is a direct instance) -- (from ANY) ensure -- from ANY generating_type_not_void: Result /= Void generator: STRING_8 -- Name of current object's generating class -- (base class of the type of which it is a direct instance) -- (from ANY) ensure -- from ANY generator_not_void: Result /= Void generator_not_empty: not Result.is_empty sorted_elements: LIST [G] -- List, in an order respecting the constraints, of all -- the elements that can be ordered in that way require sorted: done feature -- Measurement count: INTEGER_32 -- Number of elements feature -- Comparison frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void -- or attached to isomorphic object structures? -- (from ANY) ensure -- from ANY instance_free: class shallow_implies_deep: standard_equal (a, b) implies Result both_or_none_void: (a = Void) implies (Result = (b = Void)) same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b)) symmetric: Result implies deep_equal (b, a) frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached -- to objects considered equal? -- (from ANY) ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b)) frozen is_deep_equal alias "≡≡≡" (other: TOPOLOGICAL_SORTER [G]): BOOLEAN -- Are Current and other attached to isomorphic object structures? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY shallow_implies_deep: standard_is_equal (other) implies Result same_type: Result implies same_type (other) symmetric: Result implies other.is_deep_equal (Current) is_equal (other: TOPOLOGICAL_SORTER [G]): BOOLEAN -- Is other attached to an object considered -- equal to current object? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY symmetric: Result implies other ~ Current consistent: standard_is_equal (other) implies Result frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached to -- field-by-field identical objects of the same type? -- Always uses default object comparison criterion. -- (from ANY) ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b)) frozen standard_is_equal alias "" (other: TOPOLOGICAL_SORTER [G]): BOOLEAN -- Is other attached to an object of the same type -- as current object, and field-by-field identical to it? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY same_type: Result implies same_type (other) symmetric: Result implies other.standard_is_equal (Current) feature -- Status report conforms_to (other: ANY): BOOLEAN -- Does type of current object conform to type -- of other (as per Eiffel: The Language, chapter 13)? -- (from ANY) require -- from ANY other_not_void: other /= Void done: BOOLEAN -- Has topological sort been performed? fifo_output: BOOLEAN -- Are elements without constraints added to output by -- FIFO (first in first out) strategy? has_element (e: G): BOOLEAN -- Is e one of the elements to be topologically sorted? ensure exist: Result implies Result = index_of_element.has (e) and then index_of_element [e] >= 1 and then index_of_element [e] <= element_of_index.count not_exist: not Result implies not index_of_element.has (e) object_comparison: BOOLEAN -- Must `record_element` operations use `equal` rather than = -- to avoid duplicate elements? same_type (other: ANY): BOOLEAN -- Is type of current object identical to type of other? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY definition: Result = (conforms_to (other) and other.conforms_to (Current)) feature -- Status setting compare_objects -- Ensure that future `record_element` operations will use `equal` -- rather than = for comparing references. require empty: count = 0 ensure object_comparison: object_comparison compare_references -- Ensure that future record_element operations will use =` -- rather than `equal` for comparing references. require empty: count = 0 ensure reference_comparison: not object_comparison reset -- Allow further updates of the elements and constraints. ensure fresh: not done use_fifo_output -- Elements without constraints are added to output with -- FIFO (first in first out) strategy. require not_sorted: not done ensure fifo_output: fifo_output use_lifo_output -- Elements without constraints are added to output with -- LIFO (last in first out) strategy. require not_sorted: not done ensure lifo_output: not fifo_output feature -- Element change process -- Perform a topological sort over all applicable elements. -- Results are accessible through sorted, `cycle_found` and `cycle_list`. require not_sorted: not done ensure sorted: done feature -- Duplication copy (other: TOPOLOGICAL_SORTER [G]) -- Update current object using fields of object attached -- to other, so as to yield equal objects. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_equal: Current ~ other frozen deep_copy (other: TOPOLOGICAL_SORTER [G]) -- Effect equivalent to that of: -- `copy` (other . `deep_twin`) -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY deep_equal: deep_equal (Current, other) frozen deep_twin: TOPOLOGICAL_SORTER [G] -- New object structure recursively duplicated from Current. -- (from ANY) ensure -- from ANY deep_twin_not_void: Result /= Void deep_equal: deep_equal (Current, Result) frozen standard_copy (other: TOPOLOGICAL_SORTER [G]) -- Copy every field of other onto corresponding field -- of current object. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_standard_equal: standard_is_equal (other) frozen standard_twin: TOPOLOGICAL_SORTER [G] -- New object field-by-field identical to other. -- Always uses default copying semantics. -- (from ANY) ensure -- from ANY standard_twin_not_void: Result /= Void equal: standard_equal (Result, Current) frozen twin: TOPOLOGICAL_SORTER [G] -- New object equal to Current -- `twin` calls `copy`; to change copying/twinning semantics, redefine `copy`. -- (from ANY) ensure -- from ANY twin_not_void: Result /= Void is_equal: Result ~ Current feature -- Basic operations frozen default: detachable TOPOLOGICAL_SORTER [G] -- Default value of object's type -- (from ANY) frozen default_pointer: POINTER -- Default value of type POINTER -- (Avoid the need to write p.`default` for -- some p of type POINTER.) -- (from ANY) ensure -- from ANY instance_free: class default_rescue -- Process exception for routines with no Rescue clause. -- (Default: do nothing.) -- (from ANY) frozen do_nothing -- Execute a null action. -- (from ANY) ensure -- from ANY instance_free: class feature -- Output Io: STD_FILES -- Handle to standard file setup -- (from ANY) ensure -- from ANY instance_free: class io_not_void: Result /= Void out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) ensure -- from ANY out_not_void: Result /= Void print (o: detachable ANY) -- Write terse external representation of o -- on standard output. -- (from ANY) ensure -- from ANY instance_free: class frozen tagged_out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) ensure -- from ANY tagged_out_not_void: Result /= Void feature -- Platform Operating_environment: OPERATING_ENVIRONMENT -- Objects available from the operating system -- (from ANY) ensure -- from ANY instance_free: class operating_environment_not_void: Result /= Void invariant element_count: element_of_index.count = count predecessor_list_count: predecessor_count.count = count successor_list_count: successors.count = count cycle_list_iff_cycle: done implies (cycle_found = (not cycle_list.is_empty)) all_items_sorted: (done and then not cycle_found) implies (count = sorted_elements.count) no_item_forgotten: (done and then cycle_found) implies (count = sorted_elements.count + cycle_list.count) processed_count: done implies processed_count = sorted_elements.count -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) note copyright: "Copyright (c) 1984-2020, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class TOPOLOGICAL_SORTER
Classes Clusters Cluster hierarchy Chart Relations Flat contracts Go to:

-- Generated by Eiffel Studio --
For more details: eiffel.org