Skip to content

std:: unordered_setとstd:: unordered_mapのclearメソッドの計算量の記述について #1449

@math-hiyoko

Description

@math-hiyoko

std:: unordered_setとstd:: unordered_mapのclearメソッドについて、その計算量は
「本関数呼び出し前のコンテナの要素数( size() )に比例」と記述されている
https://cpprefjp.github.io/reference/unordered_set/unordered_set/clear.html
https://cpprefjp.github.io/reference/unordered_map/unordered_map/clear.html

しかし、多くの実装では、実際には本関数呼び出し前の( bucket_count() )に比例している
gccの実装: https://github.com/gcc-mirror/gcc/blob/fd50d2a24adaff9a9ba749fd0a1eb5a5c5ee35a8/libstdc%2B%2B-v3/include/bits/hashtable.h#L2707-L2720
clang LLVMの実装: https://github.com/llvm/llvm-project/blob/ad060dfa4c910e8253ba328be947ef70f6597326/libcxx/include/__hash_table#L1338-L1348

このことから、サイトの記述を実態にあったものに変えるべきである

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions