home *** CD-ROM | disk | FTP | other *** search
-
-
- {
- procedure and functions in this library
-
- ASwap swaps any two data structures w/the same size
- Identical checks if two data structures are identical
- Any gets next element out of a set (if any)
-
- }
-
- procedure aswap(var a1addr,a2addr; size : integer);
- {
- purpose swaps A <-> B; see p. 130 of TURBO Reference Manual
- last update 23 Jun 85
- }
- type
- dummyarray = array[1..maxint] of byte;
- var
- a1 : dummyarray absolute a1addr;
- a2 : dummyarray absolute a2addr;
- temp : byte;
- indx : integer;
- begin
- for indx := 1 to size do begin
- temp := a1[indx];
- a1[indx] := a2[indx];
- a2[indx] := temp
- end
- end; { of proc ASwap }
-
- function identical(var a1addr,a2addr; size : integer) : boolean;
- {
- purpose check for identical data structures
- last update 23 Jun 85
- }
- type
- dummyarray = array[1..maxint] of byte;
- var
- a1 : dummyarray absolute a1addr;
- a2 : dummyarray absolute a2addr;
- indx : integer;
- begin
- identical := false;
- for indx := 1 to size do
- if a1[indx] <> a2[indx]
- then exit;
- identical := true
- end; { of func Identical }
-
- function any(var setaddr,vaddr; size : integer) : boolean;
- {
- purpose remove lowest element in SetAddr
-
- note: for any scalar type, you can pass this
- function a set of that type, a variable
- of that type, and the size of the set.
- If the set is empty, then Any returns False;
- otherwise, it returns True, places the lowest
- (ordinal) element into VAdrr, and removes that
- same element from SetAddr. In other words, given
- the declarations
- var
- Scale : <scalar type>;
- ScaleSet : set of <scalar type>;
- then the loop
- while Any(ScaleSet,Scale,SizeOf(ScaleSet)) do begin
- ...
- end;
- will execute once for each element in ScaleSet, setting
- Scale to that element.
-
- last update 23 Jun 85
- }
- {$R-} { make sure range checking is off }
- type
- dummyset = array[1..32] of byte;
- var
- theset : dummyset absolute setaddr;
- sval : byte absolute vaddr;
- indx,tval : integer;
- ival,mask : byte;
- begin
- tval := 0;
- indx := 1;
- while (theset[indx] = 0) and (indx <= size) do begin
- indx := indx + 1;
- tval := tval + 8
- end;
- if indx > size then begin
- any := false;
- sval := 0
- end
- else begin
- any := true;
- ival := theset[indx];
- mask := $01;
- while (mask > 0) and (ival and mask = 0) do begin
- tval := tval + 1;
- mask := mask shl 1
- end;
- theset[indx] := ival xor mask;
- sval := tval
- end
- end; { of func Any }
- l + 1;
-