Ticket #18 (assigned enhancement)

Opened 3 years ago

Last modified 3 years ago

Hash maps don't define opIn and opIn_r

Reported by: Andrej08 Assigned to: schveiguy (accepted)
Priority: minor Milestone: 2.0
Component: code Version: 2.0c
Keywords: Cc:

Description

Is there any reason why Hashes in dcollections shouldn't define opIn/opIn_r? It would make them more natural to use and it would be easier to replace the use of built-in hashes without having to change the user code too much.

Change History

11/11/11 23:41:46 changed by Andrej08

  • summary changed from Hashes don't define opIn and opIn_r to Hash maps don't define opIn and opIn_r.

Well I screwed up the title, I meant hash *maps*.

11/11/11 23:43:54 changed by Andrej08

E.g.:

    bool containsKey(const(K) key) const
    {
        return !elemAt(key).empty;
    }

    /// ditto
    bool opIn_r(const(K) key)
    {
        return this.containsKey(key);
    }

11/11/11 23:47:56 changed by Andrej08

Ah wait, double-screwup. "in" for builtin hashes returns a pointer, not a boolean. Hmm..

11/12/11 00:23:21 changed by schveiguy

  • status changed from new to assigned.

elemAt should do the equivalent using cursors. However, I'm hesitant to implement opIn_r with pointers.

I don't mind aliasing opIn_r to contains. Would this be sufficient?