• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    <unordered_set>

    unordered_set

    <unordered_set> ヘッダは、キーが要素である非順序連想コンテナを提供する。

    <set> と異なり、各要素はキーの順序ではなくキーのハッシュ値に基づいて格納されるため、イテレータを用いたコンテナの走査の順序は(名前の通り)有意ではない。

    <unordered_set> ヘッダで提供されるコンテナは、operator==operator!= を除いてコンテナとしての要件を満たす。

    operator==operator!= も、コンテナの要素が一致する(あるいは一致しない)という点では他のコンテナ同様の意味を持つが、上記のとおりイテレータでの走査順が有意でないため、他のコンテナと同一のセマンティクスで(std::equal を用いて)定義することはできない。

    <unordered_set> ヘッダでは、キーの重複を許さない std::unordered_set クラステンプレート、およびキーの重複を許す std::unordered_multiset クラステンプレートを提供する。

    このヘッダでは、以下の標準ヘッダをインクルードする:

    名前 説明 対応バージョン
    unordered_set キーの重複を許さない非順序連想コンテナ(class template) C++11
    unordered_multiset キーの重複を許す非順序連想コンテナ(class template) C++11

    #include <initializer_list>
    
    namespace std {
      // クラステンプレート unordered_set
      template <class Key,
                class Hash = std::hash<Key>,
                class Pred = std::equal_to<Key>,
                class Allocator = std::allocator<Key> >
        class unordered_set;
    
      // クラステンプレート unordered_multiset
      template <class Key,
                class Hash = std::hash<Key>,
                class Pred = std::equal_to<Key>,
                class Allocator = std::allocator<Key> >
        class unordered_multiset;
    
      template <class Key, class Hash, class Pred, class Allocator>
        void swap(unordered_set<Key, Hash, Pred, Allocator>& x,
                  unordered_set<Key, Hash, Pred, Allocator>& y);
    
      template <class Key, class Hash, class Pred, class Allocator>
        void swap(unordered_multiset<Key, Hash, Pred, Allocator>& x,
                  unordered_multiset<Key, Hash, Pred, Allocator>& y);
    
      template <class Key, class Hash, class Pred, class Allocator>
        bool operator==(const unordered_set<Key, Hash, Pred, Allocator>& a,
                        const unordered_set<Key, Hash, Pred, Allocator>& b);
      template <class Key, class Hash, class Pred, class Allocator>
        bool operator!=(const unordered_set<Key, Hash, Pred, Allocator>& a,
                        const unordered_set<Key, Hash, Pred, Allocator>& b);
    
      template <class Key, class Hash, class Pred, class Allocator>
        bool operator==(const unordered_multiset<Key, Hash, Pred, Allocator>& a,
                        const unordered_multiset<Key, Hash, Pred, Allocator>& b);
      template <class Key, class Hash, class Pred, class Allocator>
        bool operator!=(const unordered_multiset<Key, Hash, Pred, Allocator>& a,
                        const unordered_multiset<Key, Hash, Pred, Allocator>& b);
    }
    

    バージョン

    言語

    • C++11

    参照