Bug 3892 – Built-in "set" type similar to associative arrays

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-03-08T01:03:00Z
Last change time
2015-06-09T05:13:45Z
Assigned to
nobody
Creator
Justin.SpahrSummers

Comments

Comment #0 by Justin.SpahrSummers — 2010-03-08T01:03:42Z
It's rather low priority, but it'd be nice to have built-in set functionality (here meaning an unordered data structure where no duplicate values can exist). Associative arrays can already fill the role to some extent if you just opt not to use the values at all, but that's a waste of storage. Syntax could even be similar, using "void" in place of a value type: --- void main () { void[string] set; set.add("hello"); assert("hello" in set); set.add("hello"); set.remove("hello"); assert(!("hello" in set)); } --- If creating a new property ("add") is out of the question, even something like... set["hello"] = true; could work.
Comment #1 by clugdbug — 2010-05-22T07:06:43Z
*** This issue has been marked as a duplicate of issue 1606 ***