Skip to content

Commit

Permalink
Fix: TIA.shuffle uses system.swap instead !
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTS committed May 24, 2015
1 parent c7eca4f commit 2ced284
Showing 1 changed file with 1 addition and 37 deletions.
38 changes: 1 addition & 37 deletions lib/utilities/types/integerarrays.simba
Original file line number Diff line number Diff line change
Expand Up @@ -518,42 +518,6 @@ begin
end;
end;

(*
TIntegerArray.exchange
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

procedure TIntegerArray.exchange(a, b: Integer);

Exchanges the values of 2 elements in the array

.. note::

- by The Mayor

Example:

.. code-block:: pascal

TIA.exchange(2, 8);

*)
procedure TIntegerArray.exchange(a, b: Integer);
var
i: Integer;
begin
if (length(self) - 1) < max(a, b) then
begin
print('TIntegerArray.exchange(): Index larger than array length', TDebug.ERROR);
exit;
end;

i := self[a];
self[a] := self[b];
self[b] := i;
end;

(*
TIntegerArray.shuffle
~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -580,7 +544,7 @@ var
i: Integer;
begin
for i := (length(self) - 1) downto 0 do
self.exchange(i, random(i + 1));
system.swap(i, random(i + 1));
end;

{$f+}

0 comments on commit 2ced284

Please sign in to comment.