Lazarus

Free Pascal => General => Topic started by: Bart on February 04, 2019, 06:56:25 pm

Title: Generic set type
Post by: Bart 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
Title: Re: Generic set type
Post by: Xor-el on February 04, 2019, 08:28:06 pm
have you tried THashSet<T> in generics.collections?
Title: Re: Generic set type
Post by: marcov on February 04, 2019, 08:29:51 pm
The NOT operator of sets causes a true set to be quite narrow..
Title: Re: Generic set type
Post by: Bart 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
Title: Re: Generic set type
Post by: Xor-el 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