[Oberon] XMLObjects.ArrayCollection Invert method

Dan Parnete dan.parnete at fastwebnet.it
Sat Oct 22 18:58:15 CEST 2005


Hello,

I propose this method for XMLObjects.ArrayCollection. It is useful for 
reordering elements:

        PROCEDURE Invert*(ptr1, ptr2: PTR);
            VAR pos1, pos2, i: LONGINT;
                ptr: PTR;
        BEGIN
            i := 0;  pos1 := -1;  pos2 := -1;
            WHILE (i < nofElems) & ((pos1 < 0) OR (pos2 < 0)) DO
                IF elems[i] = ptr1 THEN  pos1 := i  END;
                IF elems[i] = ptr2 THEN  pos2 := i  END;
                INC(i)
            END;
            IF (pos1 >= 0) & (pos2 >= 0) & (pos1 # pos2)  THEN
                ptr := elems[pos1];  elems[pos1] := elems[pos2];  
elems[pos2] := ptr
            END
        END Invert;

Thank you,
Dan Parnete


More information about the Oberon mailing list