Recent

Author Topic: Associative arrays class implementation  (Read 22118 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8819
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Associative arrays class implementation
« Reply #15 on: February 11, 2011, 12:52:25 pm »
Quote
Fgl unit fires compilation errors.
Something's wrong with your installation then because mine works fine :)

I think you better create an enumerator instead of creating ForEach method, so the iteration could be done with for...in loop.

Hmm... TFPGMap needs an Enumerator like TFPGList so it can be iterated using for..in loop as well.

BioHazard

  • Jr. Member
  • **
  • Posts: 57
  • Starless...
Re: Associative arrays class implementation
« Reply #16 on: February 11, 2011, 08:22:06 pm »
Fixed foreach added element delete updated unit code in first post...

Delete usage:

Code: [Select]
FruitColors.Delete ('Apple');

bflm

  • Jr. Member
  • **
  • Posts: 54
    • Free Pascal Random Bits
Re: Associative arrays class implementation
« Reply #17 on: February 12, 2011, 12:23:00 pm »
Just FYI, associative array is actually already implemented in fgl unit as TFPGMap. Moreover, STLPascal project has also implemented it.

Let me add also heContnrs to the list. The various map objects found there are associative arrays as well.

powtils

  • New Member
  • *
  • Posts: 18
Re: Associative arrays class implementation
« Reply #18 on: February 05, 2012, 05:45:34 am »
More associative array implementations:

TAssArr:
http://www.explainth.at/en/delphi/daa.shtml

And TDictionaries are hidden in this gem:
http://sourceforge.net/projects/fundementals/

To use tdictionaries, it is just like associative array in PHP, but strongly typed unliked weak stringly typed php.

Now if borland/LCL/fpc/msegui could just decide on making this part of the rtl/vcl or whatever instead of everyone rolling their own associative array.... Plus it's a bit annoying that everyone calls it millions of different things.. dictionaries, arrays, lists, buckets, sigh.




« Last Edit: February 05, 2012, 05:47:45 am by powtils »

dballesg

  • New Member
  • *
  • Posts: 14
Re: Associative arrays class implementation
« Reply #19 on: February 05, 2012, 03:37:02 pm »
Hi,

New to FPC + Lazarus.

But trying to convert certain Java code to Pascal I found this other collection as well:

http://code.google.com/p/delphi-coll/

Note: I didn't even't tried to use it on Lazarus yet.

David

 

TinyPortal © 2005-2018