Results 1 to 4 of 4

Thread: ClearSameTPA?

  1. #1
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default ClearSameTPA?

    I see ClearSameInteger and ClearSameIntegerAndTPA, but its not the same as what a ClearSameTPA would be. Has this been discussed? I sure it would be a useful addition to something like wizzy plugin.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  2. #2
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Code:
    program new;
    
    function clearsametpa(a: TPointArray): TPointArray;
    var
      b: TPointArray;
      len, i, n: Integer;
      switch: boolean;
    begin
      switch := false;
      len := 0;
      result := [];
      setarraylength(b, length(a));
      for i := 0 to high(a) do
      begin
        for n := 0 to high(b) do
        begin
          switch := a[i] = b[n];
          if switch then break;
        end;
        if not switch then
        begin
          b[len] := a[i];
          inc(len);
          switch := false;
        end;
      end;
      setarraylength(b, len);
      result := b;
    end;
    
    
    var a, b: array of TPoint;
    begin
      a := [point(1, 1), point(2, 2), point(2, 2), point(3, 3), point(5, 3), point(5, 3), point(3, 5)];
      b := clearsametpa(a);
      writeln(a);
      writeln(b);
    end.
    Compiled succesfully in 31 ms.
    [(1, 1), (2, 2), (2, 2), (3, 3), (5, 3), (5, 3), (3, 5)]
    [(1, 1), (2, 2), (3, 3), (5, 3), (3, 5)]


    faster in plugin, and could be optimized?

    edit: its damn slow on large sets.
    Last edited by noidea; 06-09-2011 at 02:00 AM.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  3. #3
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    ClearDoubleTPA?
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  4. #4
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Thanks.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •