1166. EXTRACTS FROM THE BASE LIBRARY SA.I --If area must be extended,ensure that space for at least --additional space item is added require valid indices:minindex <=maxindex local old_size,new size:INTEGER: new_lower,new_upper:INTEGER; do if empty_area then new_lower:=minindex; new_upper:=maxindex else if minindex lower then new_lower:=minindex else new_lower:=lower end; if maxindex upper then new_upper:=maxindex else new_upper upper end end; new_size :new_upper-new_lower +1; if not empty area then old size :area.count; if new size old size and new_size-old size additional_space then new_size:=old size additional_space end end;
1166. EXTRACTS FROM THE BASE LIBRARY §A.1 -- If area must be extended, ensure that space for at least -- additional_space item is added. require valid_indices: minindex <= maxindex local old_size, new_size: INTEGER; new_lower, new_upper: INTEGER; do if empty_area then new_lower := minindex; new_upper := maxindex else if minindex < lower then new_lower := minindex else new_lower := lower end; if maxindex > upper then new_upper := maxindex else new_upper := upper end end; new_size := new_upper - new_lower + 1; if not empty_area then old_size := area.count; if new_size > old_size and new_size - old_size < additional_space then new_size := old_size + additional_space end end;
SA.1 ARRAYS 1166. if empty_area then make area (new_size), elseif new_size old_size or new_lower lower then area:=arycpy (Sarea,new_size, lower-new_lower,capacity) end; lower:=new lower; upper:=new_upper end; empty_area:BOOLEAN is do Result :area Void or else area.count=0 end; spsubcopy (source,target:POINTER;s,e,i:INTEGER)is --Copy elements of'source'within bounds's' --and 'e'to'target'starting at index'i'. external “C” end spclearall (p:POINTER)is --Reset all items to default value. external “C end invariant consistent_size:count upper-lower +1; non_negative_count:count >=0
§A.1 ARRAYS 1166. if empty_area then make_area (new_size); elseif new_size > old_size or new_lower < lower then area := arycpy ($area, new_size, lower - new_lower, capacity) end; lower := new_lower; upper := new_upper end; empty_area: BOOLEAN is do Result := area = Void or else area.count = 0 end; spsubcopy (source, target: POINTER; s, e, i: INTEGER) is -- Copy elements of `source’ within bounds `s’ -- and `e’ to `target’ starting at index `i’. external “C” end spclearall (p: POINTER) is -- Reset all items to default value. external “C” end invariant consistent_size: count = upper - lower + 1; non_negative_count: count >= 0
1166. EXTRACTS FROM THE BASE LIBRARY SA.2 end--class ARRAY --EiffelBase:library of reusable components for ISE Eiffel 3. -Copyright(C)1986,1990,1993,1994,Interactive Software -Engineering Inc. -All rights reserved.Duplication and distribution prohibited. -270 Storke Road,Suite 7,Santa Barbara,CA 93117 USA Telephone 805-685-1006 -Fax805-685-6869 Electronic mail <info@eiffel.com> --Customer support e-mail <support@eiffel.com> A.2 LINKABLE AND BI-LINKABLE ELEMENTS indexing description: "Linkable cells containing a reference to their right neighbor"; status:“See notice at end of class'”, names:linkable,cell; representation:linked; contents:generic; date:“$Date:1995/07/2600:54:01s, revision:“$Revision:1.6$” class LINKABLE [G]inherit
1166. EXTRACTS FROM THE BASE LIBRARY §A.2 end -- class ARRAY --|---------------------------------------------------------------- --| EiffelBase: library of reusable components for ISE Eiffel 3. --| Copyright (C) 1986, 1990, 1993, 1994, Interactive Software --| Engineering Inc. --| All rights reserved. Duplication and distribution prohibited. --| --| 270 Storke Road, Suite 7, Santa Barbara, CA 93117 USA --| Telephone 805-685-1006 --| Fax 805-685-6869 --| Electronic mail <info@eiffel.com> --| Customer support e-mail <support@eiffel.com> --|---------------------------------------------------------------- A.2 LINKABLE AND BI-LINKABLE ELEMENTS indexing description: “Linkable cells containing a reference to their right neighbor”; status: “See notice at end of class”; names: linkable, cell; representation: linked; contents: generic; date: “$Date: 1995/07/26 00:54:01 $”; revision: “$Revision: 1.6 $” class LINKABLE [G] inherit
SA.2 LINKABLE AND BI-LINKABLE ELEMENTS 1166. CELL [G] export CELL,CHAIN put; (ANY item end feature--Access right:like Current; --Right neighbor feature {CELL,CHAIN --Implementation put_right(other:like Current)is --Put 'other'to the right of current cell. do right :other ensure chained:right other end; forget right is --Remove right link. do right:=Void ensure not chained:right Void end; end--class LINKABLE
§A.2 LINKABLE AND BI-LINKABLE ELEMENTS 1166. CELL [G] export {CELL, CHAIN} put; {ANY} item end feature -- Access right: like Current; -- Right neighbor feature {CELL, CHAIN} -- Implementation put_right (other: like Current) is -- Put `other’ to the right of current cell. do right := other ensure chained: right = other end; forget_right is -- Remove right link. do right := Void ensure not_chained: right = Void end; end -- class LINKABLE
1166. EXTRACTS FROM THE BASE LIBRARY SA.2 -EiffelBase:library of reusable components for ISE Eiffel 3. -Copyright(C)1986,1990,1993,1994,Interactive Software -Engineering Inc. -All rights reserved.Duplication and distribution prohibited. -270 Storke Road,Suite 7,Santa Barbara,CA 93117 USA -|Telephone805-685-1006 -|Fax805-685-6869 -Electronic mail <info@eiffel.com> --Customer support e-mail <support@eiffel.com> indexing description: "Linkable cells with a reference to the left and right neighbors"; status:"See notice at end of class"; names:bi linkable,cell; representation:linked: contents:generic; date:“$Date:1995/07/2600:53:49$; revision:“$Revision:1.7$” class BI LINKABLE [G]inherit LINKABLE [G]
1166. EXTRACTS FROM THE BASE LIBRARY §A.2 --|---------------------------------------------------------------- --| EiffelBase: library of reusable components for ISE Eiffel 3. --| Copyright (C) 1986, 1990, 1993, 1994, Interactive Software --| Engineering Inc. --| All rights reserved. Duplication and distribution prohibited. --| --| 270 Storke Road, Suite 7, Santa Barbara, CA 93117 USA --| Telephone 805-685-1006 --| Fax 805-685-6869 --| Electronic mail <info@eiffel.com> --| Customer support e-mail <support@eiffel.com> --|---------------------------------------------------------------- indexing description: “Linkable cells with a reference to the left and right neighbors”; status: “See notice at end of class”; names: bi_linkable, cell; representation: linked; contents: generic; date: “$Date: 1995/07/26 00:53:49 $”; revision: “$Revision: 1.7 $” class BI_LINKABLE [G] inherit LINKABLE [G]