D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3892 - Built-in "set" type similar to associative arrays
Summary: Built-in "set" type similar to associative arrays
Status: RESOLVED DUPLICATE of issue 1606
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-08 01:03 UTC by Justin Spahr-Summers
Modified: 2015-06-09 05:13 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Justin Spahr-Summers 2010-03-08 01:03:42 UTC
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 Don 2010-05-22 07:06:43 UTC

*** This issue has been marked as a duplicate of issue 1606 ***