Re: Help needed for ada package



Thank you for all the suggestions. Here is what I've done so far,

package body POP is

-- array of records for Person, Danger, Reported
type Individual is
record
Person : ID;
Danger : Rating;
Reported : Boolean;
end record;

type Society is array( 0 .. 1000000 ) of Individual;

Record_Counter : Natrual := 0;

-- table of associates

type Associates is array ( 0 .. 1000000 , 0 .. 1 ) of Integer;

Associates_Index : Natural := 0;
Associates_Column : Natural := 0;

--updating procedures
procedure Rate ( Citizen : in ID; Badess : in Rating); is
begin
Counter := Counter + 1;
Society( Record_Counter ) := ( Person=> Citizen, Danger=> Badness,
Reported => False );
end;

end Rate;

procedure Associate (Citizen_1, Citizen_2 : in ID) is
begin
Associates( Associates_Index, Associates_Column) := (Citizen_1,
Citizen_2);
Associates_Index := Associates_Index + 1;
Associates_Column := Associates_Column + 1;
end;
end Associate;

Most_Dangerous_Person : ID;
Most_Dangerous_Rating : Rating := 0;
Most_Dangerous_Location : Integer;

--querying functions
function Most_Dangerous return ID is

I : Integer;

begin
Most_Dangerous_Rating := 0;
Most_Dangerous_Location := 0;
for I in 0 .. Record_Counter loop
if Society(I).Danger > Most_Dangerous_Rating and
Society(I).Reported = false then
begin
Most_Dangerous_Rating := Society(I).Danger;
Most_Dangerous_Location := I;
Society(I).Reported = true;
Most_Dangerous_Person := Society(I).Citizen;
end;
end if;
end loop;
return Most_Dangerous_Person;
end;
end Most_Dangerous;

type Members_Array is array (1 .. 1000000) of Integer;

Members_Array_Counter : Natural := 0;
Member : ID;

function Next_Member return ID is

I : Integer;
J : Integer;
K : Integer;

begin
for I in 0 .. Associates_Index loop
if Associates( I, 0) = Most_Dangerous_Person then
begin
Member := Associate( I, 1)
for J in 0 .. Record_Counter loop
if Society(J).Citizen = Member and
Society(J).Reported = false then
begin
Members_Array(Members_Array_Counter) := Member;
Members_Array_Counter := Members_Array_Counter + 1;
end;
end if;
end loop;
end;
end if;
end loop;

return Members_Array(1);

for K in 0 .. Record_Counter loop
if Society(K).Citizen = Members_Array(1);
Society(K).Reported := true;
end if;
end loop;
end;
end Next_Member;

What I wanna ask is how can you reset an entire array? For
More_In_Group I want to reset the Members_Array and use a similar loop
used in Next_Member to rebuild it, this way the previous member looked
up disappears and all I would need to do is check if there are elements
still in the array to return true or false. Any suggestions?

.



Relevant Pages

  • RE: Make all variable values in a Array equal to 0
    ... just figured using an Array would reset the variables. ... Private Sub btnApply_Click ... Lether Seats (CheckBox1 and var1) ...
    (microsoft.public.excel.programming)
  • Re: can you foreach() two arrays at once ?
    ... reset $array1; ... It will stop as soon as you run out of elements in either array. ... Hmmz, haven't tried it, but won't the second list argument only be run when the first fails, so in essence 2 foreach loops after one another? ... Each time through it will process $val1 then $val2. ...
    (comp.lang.php)
  • Help! Self Induced 6540 Catastrophe
    ... I have a Sun StorageTek 6540 which had a bogus degraded drive channel ... I was told by Sun support to "reset" the array ... I'm using the sscs tool from "Common Array Manager" 5.1.0.11 to ... We have the "support data" that was collected when we ...
    (SunManagers)
  • Re: can you foreach() two arrays at once ?
    ... reset $array1; ... // $key2 and val2 contain the key and value for an element in $array2 ... It will stop as soon as you run out of elements in either array. ... echo ' '; ...
    (comp.lang.php)
  • Re: can you foreach() two arrays at once ?
    ... reset $array1; ... // $key2 and val2 contain the key and value for an element in $array2 ... It will stop as soon as you run out of elements in either array. ... echo ' '; ...
    (comp.lang.php)