This site contains older material on Eiffel. For the main Eiffel page, see http://www.eiffel.com.

EiffelBase class
(HTML page generated by ISE Eiffel 4.2)

Eiffel Class
indexing
	description: "Subsets with the associated operations, without commitment to a particular representation";
	status: "See notice at end of class";
	names: subset, set;
	access: membership;
	contents: generic;
	date: "$Date: 2007-03-30 11:10:11 -0800 (Fri, 30 Mar 2007) $";
	revision: "$Revision: 95354 $"

deferred class SUBSET [G]

inherit
	SET [G]

feature -- Comparison

	is_subset (other: like Current): BOOLEAN is
			-- Is current set a subset of other?
		require
			set_exists: other /= void;
			same_rule: object_comparison = other.object_comparison
		deferred
		end;

	is_superset (other: like Current): BOOLEAN is
			-- Is current set a superset of other?
		require
			set_exists: other /= void;
			same_rule: object_comparison = other.object_comparison
		do
			Result := other.is_subset (Current)
		end;

	disjoint (other: like Current): BOOLEAN is
			-- Do current set and other have no
			-- items in common?
		require
			set_exists: other /= void;
			same_rule: object_comparison = other.object_comparison
		local
			temp: like Current
		do
			if notempty then
				temp := duplicate (count);
				temp.intersect (other);
				Result := temp.empty
			else
				Result := true
			end
		end;

feature -- Duplication

	duplicate (n: INTEGER): SUBSET [G] is
			-- New structure containing min (n, count)
			-- items from current structure
		require
			non_negative: n >= 0
		deferred
		ensure
			correct_count_1: n <= count implies Result.count = n;
			correct_count_2: n >= count implies Result.count = count
		end;

feature -- Basic operations

	intersect (other: like Current) is
			-- Remove all items not in other.
		require
			set_exists: other /= void;
			same_rule: object_comparison = other.object_comparison
		deferred
		ensure
			is_subset_other: is_subset (other)
		end;

	merge (other: like Current) is
			-- Add all items of other.
		require
			set_exists: other /= void;
			same_rule: object_comparison = other.object_comparison
		deferred
		ensure
			is_superset: is_superset (other)
		end;

	subtract (other: like Current) is
			-- Remove all items also in other.
		require
			set_exists: other /= void;
			same_rule: object_comparison = other.object_comparison
		deferred
		ensure
			is_disjoint: disjoint (other)
		end;

	symdif (other: like Current) is
			-- Remove all items also in other, and add all
			-- items of other not already present.
		require
			set_exists: other /= void;
			same_rule: object_comparison = other.object_comparison
		local
			temp: like Current
		do
			temp := duplicate (count);
			temp.intersect (other);
			merge (other);
			subtract (temp)
		end;

end -- class SUBSET