# NameSet reference

NameSet is a helper class used as an argument for construction of other classes, most notably HashedIndexType. It's an Mtarget.

NameSet is fundamentally a reference-counted vector of strings that allows to construct them with a chain of calls. It's used to construct such things as field list for the index key. Properly, the names in the set should be different but NameSet itself doesn't check for that. The order of values in it usually matters. So its class name is slightly misleading: it's not really a set, it's a vector, but the name has been applied historically. And in the future it might include the set functionality too, by adding a quick look up of index by name.

It's defined in

    type/NameSet.h

as

    class NameSet : public Mtarget, public vector { ... }

The typical usage is like this:

    HashedIndexType::make(NameSet::make()->add("a")->add("e"))

The factory method

    make()

gives the more convenient operator priority than

    new()

. The varieties of constructors and

    make()

are:

    NameSet();
    NameSet(const vector *other);
    NameSet(const vector &other);
    static NameSet *make();
    static NameSet *make(const vector *other);
    static NameSet *make(const vector &other);

This approach to the copy constructors allows to construct from a plain vector, and since NameSet is its subclass, that works as a real copy constructor too. The constructor from a pointer makes the use of Autorefs more convenient, such as:

    Autoref ns1 = NameSet::make()->add("a")->add("b");
    Autoref ns2 = NameSet::make(ns1)->add("c");

All the vector methods are directly accessible, plus the ones added in NameSet.

    NameSet *add(const string &s);

The method for the chained construction, adds a name to the vector and returns back the same NameSet object.

    bool equals(const NameSet *other) const;

Comparison for equality. Returns true if both the name vectors are equal.

NameSet
HashedIndexType