Re: Help needed for ada package
- From: "strictly_mk@xxxxxxxxxxx" <strictly_mk@xxxxxxxxxxx>
- Date: 28 Jul 2005 03:47:28 -0700
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?
.
- Follow-Ups:
- Re: Help needed for ada package
- From: Steve
- Re: Help needed for ada package
- From: Ludovic Brenta
- Re: Help needed for ada package
- References:
- Help needed for ada package
- From: strictly_mk
- Re: Help needed for ada package
- From: Steve
- Re: Help needed for ada package
- From: strictly_mk@xxxxxxxxxxx
- Re: Help needed for ada package
- From: Steve
- Help needed for ada package
- Prev by Date: Re: Private primitive operations available to entire package hierarchy. Can it be done?
- Next by Date: Re: Ada Plugin for Eclipse
- Previous by thread: Re: Help needed for ada package
- Next by thread: Re: Help needed for ada package
- Index(es):
Relevant Pages
|