1. Computing

Set Of String in Delphi? Yes! Union, Intersection and Difference For String Lists.

By June 19, 2012

Follow me on:

in Delphi TIPS :: In Delphi, sets or set types allow you to do set type operations like union, intersection and difference on a set of ordinal values. A set is a collection of ordinal values. The values in a set have no order and it makes no sense to have a value twice (or more times) in a set. Since strings are not ordinal types you cannot have set of string declarations. Or, can you?

Read the full article to learn how to Mimic The Functionality of "set of string"


June 26, 2012 at 4:42 pm
(1) Eric says:

I really enjoy reading your articles. There are a lot of good tips in them.

Your article on Set of Strings, however, has an error in it. Your definition of difference isn’t correct. The difference of two sets is the items in the first set with any matching items from the second set removed. You don’t add anything to the first set.

So from your example, if A=[1,2,3] and B=[3,4,5], then
A difference B would be [1,2].

Your source code only needs a small tweak to be correct… remove the part of the “if” statement that adds to the initial set.

July 18, 2012 at 10:07 pm
(2) EMB says:

Eric is correct. The one you wrote about is the Symetric Difference.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2014 About.com. All rights reserved.