summaryrefslogtreecommitdiff
path: root/app/schulis-mathematiksystem/1.0/src/PAC element row
blob: 574160cd4c525d2081a4b897412de3700faba6a7 (plain)
1
2
3
PACKETelementrowDEFINES ELEMROW,:=,clear,length,insert,delete,append,remove,define,recall,field,pos,sup,inf,min,max,MIN,MAX,EXC,:LETminelement=1,maxelement=1000;LETminfield=1,maxfield=4;TYPE ELEMROW=STRUCT(INTused,ROWmaxelementROWmaxfieldINTf);OP:=(ELEMROW VARd,ELEMROW CONSTs):CONCR(d):=CONCR(s);END OP:=;PROCclear(ELEMROW VARt):t.used:=0;END PROCclear;INT PROClength(ELEMROW CONSTt):t.usedEND PROClength;PROCinsert(ELEMROW VARt,INT CONSTk):insert(t,k,0,0,0,0);END PROCinsert;PROCinsert(ELEMROW VARt,INT CONSTk,INT CONSTa,b,c,d):checkelement(k," bei 'insert'");checkfilled(t.used," bei 'insert'");INT VARi:=t.used;WHILEi>=kREPt.f[i+1]:=t.f[i];iDECR1PER;t.usedINCR1;t.f[k][1]:=a;t.f[k][2]:=b;t.f[k][3]:=c;t.f[k][4]:=d;END PROCinsert;PROCdelete(ELEMROW VARt,INT CONSTk):IFk<minelementORk>t.usedTHEN LEAVEdeleteFI;INT VARi:=k;WHILEi<t.usedREPt.f[i]:=t.f[i+1];iINCR1PER;t.usedDECR1;END PROCdelete;PROCdelete(ELEMROW VARt,INT CONSTk,INT VARa,b,c,d):IFk<minelementORk>t.usedTHEN LEAVEdeleteFI;a:=t.f[k][1];b:=t.f[k][2];c:=t.f[k][3];d:=t.f[k][4];INT VARi:=k;WHILEi<t.usedREPt.f[i]:=t.f[i+1];iINCR1PER;t.usedDECR1;END PROCdelete;PROCappend(ELEMROW VARt):append(t,0,0,0,0);END PROCappend;PROCappend(ELEMROW VARt,INT CONSTa,b,c,d):checkfilled(t.used," bei 'append'");t.usedINCR1;t.f[t.used][1]:=a;t.f[t.used][2]:=b;t.f[t.used][3]:=c;t.f[t.used][4]:=d;END PROCappend;PROCremove(ELEMROW VARt):checkempty(t.used," bei 'remove'");t.usedDECR1;END PROCremove;PROCremove(ELEMROW VARt,INT VARa,b,c,d):checkempty(t.used," bei 'remove'");a:=t.f[t.used][1];b:=t.f[t.used][2];c:=t.f[t.used][3];d:=t.f[t.used][4];t.usedDECR1;END PROCremove;PROCdefine(ELEMROW VARt,INT CONSTk,INT CONSTa,b,c,d):checkelement(k," bei 'define'");WHILEt.used<kREPappend(t)PER;t.f[k][1]:=a;t.f[k][2]:=b;t.f[k][3]:=c;t.f[k][4]:=d;END PROCdefine;PROCrecall(ELEMROW CONSTt,INT CONSTk,INT VARa,b,c,d):IFk<minelementORk>t.usedTHENa:=0;b:=0;c:=0;d:=0;LEAVErecallFI;a:=t.f[k][1];b:=t.f[k][2];c:=t.f[k][3];d:=t.f[k][4];END PROCrecall;PROCfield(ELEMROW VARt,INT CONSTk,n,INT CONSTv):checkelement(k," bei 'field'");checkfield(n," bei 'field'");WHILEt.used<kREPappend(t)PER;t.f[k][n]:=v;END PROCfield;INT PROCfield(ELEMROW CONSTt,INT CONSTk,n):IFk<minelementORk>t.usedORn<minfieldORn>maxfieldTHEN LEAVEfieldWITH0;FI;t.f[k][n]END PROCfield;PROCcheckempty(INT CONSTu,TEXT CONSTmsg):IFu<minelementTHENerrorstop("Element-Anzahl = "+text(u)+" < "+text(minelement)+msg)FI;END PROCcheckempty;PROCcheckfilled(INT CONSTu,TEXT CONSTmsg):IFu>=maxelementTHENerrorstop("Element-Anzahl = "+text(u)+" >= "+text(maxelement)+msg)FI;END PROCcheckfilled;PROCcheckelement(INT CONSTn,TEXT CONSTmsg):IFn<minelementTHENerrorstop("Element-Nummer = "+text(n)+" < "+text(minelement)+msg)FI;IFn>maxelementTHENerrorstop("Element-Nummer = "+text(n)+" > "+text(maxelement)+msg)FI;END PROCcheckelement;PROCcheckfield(INT CONSTn,TEXT CONSTmsg):IFn<minfieldTHENerrorstop("Feld-Nummer = "+text(n)+" < "+text(minfield)+msg)FI;IFn>maxfieldTHENerrorstop("Feld-Nummer = "+text(n)+" > "+text(maxfield)+msg)FI;END PROCcheckfield;INT PROCpos(ELEMROW CONSTt,INT CONSTa,b,c,d):pos(t,a,b,c,d,1)END PROCpos;INT PROCpos(ELEMROW CONSTt,INT CONSTa,b,c,d,INT CONSTbeg):INT VARp:=1MAXbegMINt.used+1;WHILEp<=t.usedREP IFt.f[p][1]=aANDt.f[p][2]=bANDt.f[p][3]=cANDt.f[p][4]=dTHEN LEAVEposWITHp;FI;pINCR1;PER;0END PROCpos;INT PROCsup(ELEMROW CONSTt,INT CONSTxp,yp):sup(t,xp,yp,xp,yp,1)END PROCsup;INT PROCsup(ELEMROW CONSTt,INT CONSTxp,yp,INT CONSTbeg):sup(t,xp,yp,xp,yp,beg)END PROCsup;INT PROCsup(ELEMROW CONSTt,INT CONSTxb,yb,xe,ye):sup(t,xb,yb,xe,ye,1)END PROCsup;INT PROCsup(ELEMROW CONSTt,INT CONSTxb,yb,xe,ye,INT CONSTbeg):INT VARp:=1MAXbegMINt.used+1;WHILEp<=t.usedREP IFt.f[p][1]<=xbANDt.f[p][2]<=ybANDt.f[p][3]>=xeANDt.f[p][4]>=yeTHEN LEAVEsupWITHp;FI;pINCR1;PER;0END PROCsup;INT PROCinf(ELEMROW CONSTt,INT CONSTxb,yb,xe,ye):inf(t,xb,yb,xe,ye,t.used)END PROCinf;INT PROCinf(ELEMROW CONSTt,INT CONSTxb,yb,xe,ye,INT CONSTend):INT VARp:=0MAXendMINt.used;WHILEp>=1REP IFt.f[p][1]<=xbANDt.f[p][2]<=ybANDt.
f[p][3]>=xeANDt.f[p][4]>=yeTHEN LEAVEinfWITHp;FI;pDECR1;PER;0END PROCinf;PROCmin(ELEMROW CONSTt,INT CONSTp,q,INT VARxb,yb,xe,ye):recall(t,p,xb,yb,xe,ye);min(t,q,xb,yb,xe,ye);END PROCmin;PROCmin(ELEMROW CONSTt,INT CONSTp,INT VARxb,yb,xe,ye):IFp<1ORp>t.usedTHEN LEAVEminFI;INT VARxl,yl,xh,yh;recall(t,p,xl,yl,xh,yh);xb:=xlMAXxb;yb:=ylMAXyb;xe:=xhMINxe;ye:=yhMINye;END PROCmin;PROCmax(ELEMROW CONSTt,INT CONSTp,q,INT VARxb,yb,xe,ye):recall(t,p,xb,yb,xe,ye);max(t,q,xb,yb,xe,ye);END PROCmax;PROCmax(ELEMROW CONSTt,INT CONSTp,INT VARxb,yb,xe,ye):IFp<1ORp>t.usedTHEN LEAVEmaxFI;INT VARxl,yl,xh,yh;recall(t,p,xl,yl,xh,yh);xb:=xlMINxb;yb:=ylMINyb;xe:=xhMAXxe;ye:=yhMAXye;END PROCmax;INT OP MIN(INT CONSTa,b):IFa<bTHENaELSEbFI END OP MIN;INT OP MAX(INT CONSTa,b):IFa>bTHENaELSEbFI END OP MAX;OP EXC(INT VARa,b):INT CONSTd:=a;a:=b;b:=d;END OP EXC;END PACKETelementrow;