indexing
	description: "Sets of integers with a finite number of items"
	legal: "See notice at end of class."
	status: "See notice at end of class."
	date: "$Date: 2006-01-22 18:25:44 -0800 (Sun, 22 Jan 2006) $"
	revision: "$Revision: 56675 $"

class interface
	FIXED_INTEGER_SET

create 
	make (n: INTEGER_32)
			-- Make set for at most `n' integers from 1 to `n'.
		require
			n_positive: n > 0
		ensure
			set_empty: is_empty


create {FIXED_INTEGER_SET}
	boolean_set_make (n: INTEGER_32)
			-- Allocate area of `n' booleans.
			-- (from BOOL_STRING)
		require -- from BOOL_STRING
			non_negative_size: n >= 0
		ensure -- from BOOL_STRING
			correct_allocation: count = n

feature -- Initialization

	make (n: INTEGER_32)
			-- Make set for at most `n' integers from 1 to `n'.
		require
			n_positive: n > 0
		ensure
			set_empty: is_empty

	boolean_set_make (n: INTEGER_32)
			-- Allocate area of `n' booleans.
			-- (from BOOL_STRING)
		require -- from BOOL_STRING
			non_negative_size: n >= 0
		ensure -- from BOOL_STRING
			correct_allocation: count = n
	
feature -- Access

	generating_type: STRING_8
			-- Name of current object's generating type
			-- (type of which it is a direct instance)
			-- (from ANY)

	generator: STRING_8
			-- Name of current object's generating class
			-- (base class of the type of which it is a direct instance)
			-- (from ANY)

	has (i: INTEGER_32): BOOLEAN
			-- Is `i' in set?
		require
			index_large_enough: 1 <= i
			index_small_enough: i <= count

	is_empty: BOOLEAN
			-- Is current set empty?

	item alias "[]" (i: INTEGER_32): BOOLEAN assign put
			-- Boolean at `i'-th position,
			-- beginning at left, 1 origin
			-- Was declared in BOOL_STRING as synonym of infix "@".
			-- (from BOOL_STRING)
		require -- from TO_SPECIAL
			valid_index: valid_index (i)

	largest: INTEGER_32
			-- Largest integer in set;
			-- 0 if set empty

	next (p: INTEGER_32): INTEGER_32
			-- Next integer in set following `p';
			-- count + 1 if `p' equals largest
		require
			p_in_set: p >= 1 and p <= count

	smallest: INTEGER_32
			-- Smallest integer in set;
			-- count + 1 if set empty

	infix "@" (i: INTEGER_32): BOOLEAN assign put
			-- Boolean at `i'-th position,
			-- beginning at left, 1 origin
			-- Was declared in BOOL_STRING as synonym of item.
			-- (from BOOL_STRING)
		require -- from TO_SPECIAL
			valid_index: valid_index (i)
	
feature -- Measurement

	count: INTEGER_32
			-- Number of boolean in the area.
			-- (from BOOL_STRING)
	
feature -- Comparison

	frozen deep_equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' either both void
			-- or attached to isomorphic object structures?
			-- (from ANY)
		ensure -- from ANY
			shallow_implies_deep: standard_equal (some, other) implies Result
			both_or_none_void: (some = Void) implies (Result = (other = Void))
			same_type: (Result and (some /= Void)) implies some.same_type (other)
			symmetric: Result implies deep_equal (other, some)

	frozen equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' either both void or attached
			-- to objects considered equal?
			-- (from ANY)
		ensure -- from ANY
			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.is_equal (other))

	frozen standard_equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' 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
			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.standard_is_equal (other))

	frozen standard_is_equal (other: like Current): 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

	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))

	valid_index (i: INTEGER_32): BOOLEAN
			-- Is `i' within the bounds of Current?
			-- (from BOOL_STRING)
	
feature -- Element change

	all_false
			-- Set all booleans to false.
			-- (from BOOL_STRING)

	all_true
			-- Set all booleans to true.
			-- (from BOOL_STRING)

	put (i: INTEGER_32)
			-- Insert `i' into set.
		require
			index_large_enough: 1 <= i
			index_small_enough: i <= count
		ensure
			is_in_set: has (i)

	bool_string_put (v: like item; i: INTEGER_32)
			-- Put boolean `v' at `i'-th position
			-- beginning at left, 1 origin.
			-- (from BOOL_STRING)
		require -- from TO_SPECIAL
			valid_index: valid_index (i)
		ensure -- from TO_SPECIAL
			inserted: item (i) = v
	
feature -- Removal

	remove (i: INTEGER_32)
			-- Delete `i' from set.
		require
			index_large_enough: 1 <= i
			index_small_enough: i <= count
		ensure
			is_not_in_set: not has (i)
	
feature -- Conversion

	to_c: ANY
	
feature -- Duplication

	copy (other: like Current)
			-- 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: is_equal (other)

	frozen deep_copy (other: like Current)
			-- 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: like Current
			-- New object structure recursively duplicated from Current.
			-- (from ANY)
		ensure -- from ANY
			deep_equal: deep_equal (Current, Result)

	frozen standard_copy (other: like Current)
			-- 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: like Current
			-- 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: like Current
			-- New object equal to `Current'
			-- twin calls copy; to change copying/twining semantics, redefine copy.
			-- (from ANY)
		ensure -- from ANY
			twin_not_void: Result /= Void
			is_equal: Result.is_equal (Current)
	
feature -- Basic operations

	frozen default: like Current
			-- 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)

	default_rescue
			-- Process exception for routines with no Rescue clause.
			-- (Default: do nothing.)
			-- (from ANY)

	frozen do_nothing
			-- Execute a null action.
			-- (from ANY)

	left_shifted (n: INTEGER_32): like Current
			-- Left shifted 'Current' set, by `n' positions
			-- (from BOOL_STRING)
		require -- from BOOL_STRING
			non_negative_shift: n >= 0

	right_shifted (n: INTEGER_32): like Current
			-- Right shifted 'Current' set, by `n' positions
			-- (from BOOL_STRING)
		require -- from BOOL_STRING
			non_negative_shift: n >= 0

	infix "and" (other: like Current): like Current
			-- Logical and of 'Current' and `other'
			-- (from BOOL_STRING)
		require -- from BOOL_STRING
			other_not_void: other /= Void
			same_size: other.count = count

	prefix "not": like Current
			-- Negation of 'Current'
			-- (from BOOL_STRING)

	infix "or" (other: like Current): like Current
			-- Logical or of 'Current' and `other'
			-- (from BOOL_STRING)
		require -- from BOOL_STRING
			other_not_void: other /= Void
			same_size: other.count = count

	infix "xor" (other: like Current): like Current
			-- Logical exclusive or of 'Current' and `other'
			-- (from BOOL_STRING)
		require -- from BOOL_STRING
			other_not_void: other /= Void
			same_size: other.count = count
	
feature -- Output

	io: STD_FILES
			-- Handle to standard file setup
			-- (from ANY)

	out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- Was declared in ANY as synonym of tagged_out.
			-- (from ANY)

	print
			-- List all items in set.

	out_print (some: ANY)
			-- Write terse external representation of `some'
			-- on standard output.
			-- (from ANY)

	frozen tagged_out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- Was declared in ANY as synonym of out.
			-- (from ANY)
	
feature -- Platform

	operating_environment: OPERATING_ENVIRONMENT
			-- Objects available from the operating system
			-- (from ANY)
	
invariant
	positive_size: count > 0

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

indexing
	copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	source: "[
		Eiffel Software
		356 Storke Road, 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 FIXED_INTEGER_SET