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