Results 1 to 10 of 10

Thread: Sorting tiles

  1. #1
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default Sorting tiles

    I have this situation where i get a bunch of tiles and store them in an array. I then have to delete the duplicates from this array, how would i go about doing it efficiently? I tried 'if tile in array'(this isn't the exact syntax), but it doesn't work.

  2. #2
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    When you say it didn't work, did it just take forever? Or did it literally provide you no good results?

  3. #3
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    It said type mismatch. (The 'in' method works if i try to search for integers in a variantarray, but variant doesn't take TTiles or TPoints)

    Edit: Woot! 500 posts!
    Last edited by KingKong; 02-04-2011 at 06:48 AM.

  4. #4
    Join Date
    Oct 2008
    Posts
    500
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Check for Fakawi's thread where he asks for a function that removes duplicates from an array.

    Somone posted a nice one.

  5. #5
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Post the link?plz?

  6. #6
    Join Date
    Oct 2008
    Posts
    500
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry its in members forum. Doubt it will be a problem to share the function though.

    Complete credits to Frement.

    Simba Code:
    function array_unique(src: TVariantArray): TVariantArray;
    var I, O, E: Integer;
        Skip: Boolean;
    begin
      SetArrayLength(Result, 1);
      Skip := False;
      E := 0;
      for I := 0 to High(src) do begin
        for O := 0 to High(Result) do begin
          if (Result[O] = src[I]) then begin
            Skip := True;
            break;
          end;
        end;
        if not (Skip) then begin
          SetArrayLength(Result, E+1);
          Result[E] := src[I];
          Inc(E);
        end;
        Skip := False;
      end;
    end;

  7. #7
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    ^It doesn't work, since variant can't take ttiles/tpoints

  8. #8
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    ^ Then couldn't you just set the var as a TTileArray?
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  9. #9
    Join Date
    Dec 2010
    Posts
    808
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Umm surely you just change TVariant to TTile...

    Edit: gah mobile internet give ninjaa advantage xD ^
    -Boom
    Last edited by **BANNED The Man; 02-04-2011 at 07:55 AM.

  10. #10
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by Rich View Post
    ^ Then couldn't you just set the var as a TTileArray?
    thanks for pointing it out.

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
  •