Recent

Author Topic: Generic set type  (Read 1934 times)

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Generic set type
« on: February 04, 2019, 06:56:25 pm »
Hi,

Does freepascal have a generic set type, by which I mean a type that supports all set operators and the "set" can consist of any type (not just ordinals), so you can have a set of DWORDs, strings, objects, vectors you name it?

Bart

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: Generic set type
« Reply #1 on: February 04, 2019, 08:28:06 pm »
have you tried THashSet<T> in generics.collections?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Generic set type
« Reply #2 on: February 04, 2019, 08:29:51 pm »
The NOT operator of sets causes a true set to be quite narrow..

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Generic set type
« Reply #3 on: February 04, 2019, 10:42:56 pm »
have you tried THashSet<T> in generics.collections?

I don't use fpc trunk ATM.
But would that allow syntax like ASet := ASet + [AMember]?

Bart

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: Generic set type
« Reply #4 on: February 05, 2019, 12:05:40 am »
But would that allow syntax like ASet := ASet + [AMember]?

nope but it has methods to do similar set operations like UnionWith, IntersectWith, ExceptWith and so on.

 

TinyPortal © 2005-2018