Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

structure.sort

Class DS_ARRAY_SORTER


Known direct descendants

DS_ARRAY_BUBBLE_SORTER, DS_ARRAY_QUICK_SORTER, DS_ARRAY_SHELL_SORTER

Features

Invariants

indexing

description

Array sorters

library

Gobo Eiffel Structure Library

copyright

Copyright (c) 2001, Eric Bezault and others

license

Eiffel Forum License v2 (see forum.txt)

date

$Date: 2004/11/14 15:10:15 $

revision

$Revision: 1.8 $

deferred class

DS_ARRAY_SORTER [G]

feature -- Access

comparator: KL_PART_COMPARATOR [G]

-- Comparison criterion

feature -- Status report

reverse_sorted (a_container: ARRAY [G]): BOOLEAN

-- Is a_container sorted in decreasing order?

require
a_container_not_void: a_container /= Void
reverse_subsorted (a_container: ARRAY [G]; lower, upper: INTEGER): BOOLEAN

-- Is a_container sorted in decreasing order
-- within bounds lower..upper?

require
a_container_not_void: a_container /= Void
valid_lower: a_container.lower <= lower and lower <= a_container.upper
valid_upper: a_container.lower <= upper and upper <= a_container.upper
valid_bounds: lower <= upper
sorted (a_container: ARRAY [G]): BOOLEAN

-- Is a_container sorted in increasing order?

require
a_container_not_void: a_container /= Void
sorted_with_comparator (a_container: ARRAY [G]; a_comparator: KL_PART_COMPARATOR [G]): BOOLEAN

-- Is a_container sorted according to
-- a_comparator's comparison criterion?

require
a_container_not_void: a_container /= Void
a_comparator_not_void: a_comparator /= Void
subsorted (a_container: ARRAY [G]; lower, upper: INTEGER): BOOLEAN

-- Is a_container sorted in increasing order
-- within bounds lower..upper?

require
a_container_not_void: a_container /= Void
valid_lower: a_container.lower <= lower and lower <= a_container.upper
valid_upper: a_container.lower <= upper and upper <= a_container.upper
valid_bounds: lower <= upper
subsorted_with_comparator (a_container: ARRAY [G]; a_comparator: KL_PART_COMPARATOR [G]; lower, upper: INTEGER): BOOLEAN

-- Is a_container sorted according to a_comparator's
-- comparison criterion within bounds lower..upper?

require
a_container_not_void: a_container /= Void
a_comparator_not_void: a_comparator /= Void
valid_lower: a_container.lower <= lower and lower <= a_container.upper
valid_upper: a_container.lower <= upper and upper <= a_container.upper
valid_bounds: lower <= upper

feature -- Sort

reverse_sort (a_container: ARRAY [G])

-- Sort a_container in decreasing order.

require
a_container_not_void: a_container /= Void
ensure
sorted: reverse_sorted (a_container)
reverse_subsort (a_container: ARRAY [G]; lower, upper: INTEGER)

-- Sort a_container in decreasing order
-- within bounds lower..upper.

require
a_container_not_void: a_container /= Void
valid_lower: a_container.lower <= lower and lower <= a_container.upper
valid_upper: a_container.lower <= upper and upper <= a_container.upper
valid_bounds: lower <= upper
ensure
subsorted: reverse_subsorted (a_container, lower, upper)
sort (a_container: ARRAY [G])

-- Sort a_container in increasing order.

require
a_container_not_void: a_container /= Void
ensure
sorted: sorted (a_container)
sort_with_comparator (a_container: ARRAY [G]; a_comparator: KL_PART_COMPARATOR [G])

-- Sort a_container according to
-- a_comparator's comparison criterion?

require
a_container_not_void: a_container /= Void
a_comparator_not_void: a_comparator /= Void
ensure
sorted: sorted_with_comparator (a_container, a_comparator)
subsort (a_container: ARRAY [G]; lower, upper: INTEGER)

-- Sort a_container in increasing order
-- within bounds lower..upper.

require
a_container_not_void: a_container /= Void
valid_lower: a_container.lower <= lower and lower <= a_container.upper
valid_upper: a_container.lower <= upper and upper <= a_container.upper
valid_bounds: lower <= upper
ensure
subsorted: subsorted (a_container, lower, upper)
subsort_with_comparator (a_container: ARRAY [G]; a_comparator: KL_PART_COMPARATOR [G]; lower, upper: INTEGER)

-- Sort a_container according to a_comparator's
-- comparison criterion within bounds lower..upper?

require
a_container_not_void: a_container /= Void
a_comparator_not_void: a_comparator /= Void
valid_lower: a_container.lower <= lower and lower <= a_container.upper
valid_upper: a_container.lower <= upper and upper <= a_container.upper
valid_bounds: lower <= upper
ensure
subsorted: subsorted_with_comparator (a_container, a_comparator, lower, upper)

invariant

comparator_not_void: comparator /= Void

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end