hash_multiset(STL/CLR)
템플릿 클래스는 양방향 액세스 권한이 있는 요소의 다양한 길이 시퀀스를 제어하는 개체를 설명합니다. 컨테이너 hash_multiset 를 사용하여 요소 시퀀스를 해시 테이블로 관리하고, 각 테이블 항목은 노드의 양방향 연결된 목록을 저장하고, 각 노드는 하나의 요소를 저장합니다. 각 요소의 값은 시퀀스 순서를 지정하기 위해 키로 사용됩니다.
아래 GValue 설명에서는 후자가 ref 형식이 아니면 키와 같 GKey으며, 이 경우 키 와 Key^같습니다.
구문
template<typename Key>
ref class hash_multiset
: public
System::ICloneable,
System::Collections::IEnumerable,
System::Collections::ICollection,
System::Collections::Generic::IEnumerable<GValue>,
System::Collections::Generic::ICollection<GValue>,
System::Collections::Generic::IList<GValue>,
Microsoft::VisualC::StlClr::IHash<Gkey, GValue>
{ ..... };
매개 변수
Key
제어되는 시퀀스에 있는 요소의 키 구성 요소 형식입니다.
요구 사항
헤더:< cliext/hash_set>
네임스페이스: cliext
선언
| 연산자 | 설명 |
|---|---|
| hash_multiset::operator=(STL/CLR) | 제어되는 시퀀스를 바꿉니다. |
인터페이스
| 인터페이스 | 설명 |
|---|---|
| ICloneable | 개체를 복제합니다. |
| IEnumerable | 요소를 통해 시퀀스합니다. |
| ICollection | 요소 그룹을 유지 관리합니다. |
| IEnumerable<T> | 형식화된 요소를 통해 시퀀스합니다. |
| ICollection<T> | 형식화된 요소 그룹을 유지 관리합니다. |
| IHashKey<, 값> | 일반 컨테이너를 유지 관리합니다. |
설명
개체는 양방향 연결된 목록에서 개별 노드로 제어하는 시퀀스에 대한 스토리지를 할당하고 해제합니다. 액세스 속도를 높이기 위해 개체는 목록(해시 테이블)에 다양한 길이의 포인터 배열을 유지 관리하여 전체 목록을 하위 목록 또는 버킷의 시퀀스로 효과적으로 관리합니다. 한 노드의 내용을 다른 노드에 복사하지 않고 노드 간 링크를 변경하여 순서가 유지되는 버킷에 요소를 삽입합니다. 즉, 나머지 요소를 방해하지 않고 요소를 자유롭게 삽입하고 제거할 수 있습니다.
개체는 STL/CLR(hash_set::key_compare) 형식의 저장된 대리자 개체를 호출하여 제어하는 각 버킷을 정렬합니다. hash_set 만들 때 저장된 대리자 개체를 지정할 수 있습니다. 대리자 개체를 지정하지 않으면 기본값은 비교 operator<=(key_type, key_type)입니다.
STL/CLR()(hash_set::key_comp) 멤버 함수를 호출하여 저장된 대리자 개체에 액세스합니다. 이러한 대리자 개체는 hash_set::key_type(STL/CLR) 형식의 키 간에 동등한 순서를 정의해야 합니다. 즉, 두 키 X 에 대해 다음 Y을 수행합니다.
key_comp()(X, Y) 는 모든 호출에서 동일한 부울 결과를 반환합니다.
true XY 이면 key_comp()(X, Y) && key_comp()(Y, X) 동일한 순서를 가지고 있다고 합니다.
eqivalent 순서 지정처럼 operator<=(key_type, key_type)operator>=(key_type, key_type) 동작하거나 operator==(key_type, key_type) eqivalent 순서를 정의하는 모든 순서 지정 규칙입니다.
컨테이너는 키가 동일한 순서를 갖는 요소(및 동일한 정수 값에 대한 해시)만 버킷 내에 인접하도록 합니다. 템플릿 클래스 hash_set(STL/CLR)와 달리 템플릿 클래스 hash_multiset 의 개체는 모든 요소에 대한 키가 고유할 필요가 없습니다. (두 개 이상의 키는 동일한 순서를 가질 수 있습니다.)
개체는 stL/CLR(hash_set:hasher) 형식의 저장된 대리자 개체를 호출하여 지정된 순서 지정 키를 포함해야 하는 버킷을 결정합니다. STL/CLR(hash_set::hash_delegate)() 멤버 함수를 호출하여 키 값에 따라 정수 값을 가져와서 이 저장된 개체에 액세스합니다. hash_set 만들 때 저장된 대리자 개체를 지정할 수 있습니다. 대리자 개체를 지정하지 않으면 기본값은 함수 System::Object::hash_value(key_type)입니다. 즉, 모든 키 X 에 대해 다음을 Y수행합니다.
hash_delegate()(X) 는 모든 호출에서 동일한 정수 결과를 반환합니다.
동일한 순서가 hash_delegate()(X) 있는 Y 경우 X 동일한 정수 결과를 hash_delegate()(Y)반환해야 합니다.
각 요소는 키와 값으로 사용됩니다. 시퀀스는 적어도 가장 좋은 경우 시퀀스의 요소 수(상수 시간)와 무관한 여러 연산을 사용하여 임의 요소를 조회, 삽입 및 제거할 수 있는 방식으로 표현됩니다. 또한, 요소를 삽입할 경우 어떤 반복기도 무효화되지 않으며, 요소를 제거할 경우 제거된 요소를 가리키고 있는 반복기만 무효화됩니다.
그러나 해시된 값이 균일하게 분산되지 않으면 해시 테이블이 퇴화될 수 있습니다. 극단적인 경우 항상 동일한 값을 반환하는 해시 함수의 경우 조회, 삽입 및 제거는 시퀀스의 요소 수(선형 시간)에 비례합니다. 컨테이너는 적절한 해시 함수, 평균 버킷 크기 및 해시 테이블 크기(총 버킷 수)를 선택하려고 하지만 이러한 선택 항목을 모두 재정의할 수 있습니다. 예를 들어 함수 hash_set::max_load_factor(STL/CLR) 및 hash_set::rehash(STL/CLR)를 참조하세요.
hash_multiset 양방향 반복기를 지원합니다. 즉, 제어되는 시퀀스에서 요소를 지정하는 반복기가 제공되면 인접 요소로 한 단계씩 나아갈 수 있습니다. 특수 헤드 노드는 hash_multiset::end(STL/CLR)()에서 반환된 반복기에 해당합니다. 제어되는 시퀀스의 마지막 요소(있는 경우)에 도달하도록 이 반복기를 감소할 수 있습니다. 헤드 노드에 도달하기 위해 hash_multiset 반복기를 증분할 수 있습니다. 그러면 이 반복기가 같음과 end()비교됩니다. 그러나 에서 반환 end()한 반복기를 역참조할 수는 없습니다.
임의 액세스 반복기가 필요한 숫자 위치를 지정하면 hash_multiset 요소를 직접 참조할 수 없습니다.
hash_multiset 반복기는 연결된 hash_multiset 노드에 핸들을 저장합니다. 이 노드는 연결된 컨테이너에 대한 핸들을 저장합니다. 연결된 컨테이너 개체에서만 반복기를 사용할 수 있습니다. 연결된 hash_multiset 노드가 일부 hash_multiset 연결되어 있는 한 hash_multiset 반복기는 유효한 상태로 유지됩니다. 또한 유효한 반복기는 역참조할 수 있습니다. 이 반복기를 사용하여 지정된 end()요소 값에 액세스하거나 변경할 수 있습니다.
요소를 지우거나 제거하면 저장된 값에 대한 소멸자가 호출됩니다. 컨테이너를 삭제하면 모든 요소가 지워집니다. 따라서 요소 형식이 ref 클래스인 컨테이너는 컨테이너보다 더 오래 살 요소가 없도록 합니다. 그러나 핸들 컨테이너는 해당 요소를 삭제 하지 않습니다.
멤버
hash_multiset::begin(STL/CLR)
제어되는 시퀀스의 시작을 지정합니다.
구문
iterator begin();
설명
멤버 함수는 제어되는 시퀀스의 첫 번째 요소를 지정하거나 빈 시퀀스의 끝 바로 너머를 지정하는 양방향 반복기를 반환합니다. 이를 통해 제어되는 시퀀스의 current 시작을 지정하는 반복기를 가져올 수 있지만 제어되는 시퀀스의 길이가 변경되면 상태가 변경될 수 있습니다.
예제
// cliext_hash_multiset_begin.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// inspect first two items
Myhash_multiset::iterator it = c1.begin();
System::Console::WriteLine("*begin() = {0}", *it);
System::Console::WriteLine("*++begin() = {0}", *++it);
return (0);
}
a b c
*begin() = a
*++begin() = b
hash_multiset::bucket_count(STL/CLR)
버킷 수를 계산합니다.
구문
int bucket_count();
설명
멤버 함수는 현재 버킷 수를 반환합니다. 이를 사용하여 해시 테이블의 크기를 확인합니다.
예제
// cliext_hash_multiset_bucket_count.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// inspect current parameters
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
System::Console::WriteLine();
// change max_load_factor and redisplay
c1.max_load_factor(0.25f);
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
System::Console::WriteLine();
// rehash and redisplay
c1.rehash(100);
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
return (0);
}
a b c
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25
bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25
hash_multiset::clear(STL/CLR)
모든 요소를 제거합니다.
구문
void clear();
설명
멤버 함수는 hash_multiset::erase(STL/CLR)(hash_multiset::begin(STL/CLR)(),hash_multiset::end(STL/CLR)())를 효과적으로 호출합니다. 이를 사용하여 제어된 시퀀스가 비어 있는지 확인합니다.
예제
// cliext_hash_multiset_clear.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// clear the container and reinspect
c1.clear();
System::Console::WriteLine("size() = {0}", c1.size());
// add elements and clear again
c1.insert(L'a');
c1.insert(L'b');
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
c1.clear();
System::Console::WriteLine("size() = {0}", c1.size());
return (0);
}
a b c
size() = 0
a b
size() = 0
hash_multiset::const_iterator(STL/CLR)
제어되는 시퀀스에 대한 상수 반복기의 형식입니다.
구문
typedef T2 const_iterator;
설명
이 형식은 제어되는 시퀀스에 대한 상수 양방향 반복기 역할을 할 수 있는 지정되지 않은 형식 T2 의 개체를 설명합니다.
예제
// cliext_hash_multiset_const_iterator.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c"
Myhash_multiset::const_iterator cit = c1.begin();
for (; cit != c1.end(); ++cit)
System::Console::Write("{0} ", *cit);
System::Console::WriteLine();
return (0);
}
a b c
hash_multiset::const_reference(STL/CLR)
요소에 대한 상수 참조의 형식입니다.
구문
typedef value_type% const_reference;
설명
이 형식은 요소에 대한 상수 참조를 설명합니다.
예제
// cliext_hash_multiset_const_reference.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
Myhash_multiset::const_iterator cit = c1.begin();
for (; cit != c1.end(); ++cit)
{ // get a const reference to an element
Myhash_multiset::const_reference cref = *cit;
System::Console::Write("{0} ", cref);
}
System::Console::WriteLine();
return (0);
}
a b c
hash_multiset::const_reverse_iterator(STL/CLR)
제어되는 시퀀스에 대한 상수 역방향 반복기의 형식입니다.
구문
typedef T4 const_reverse_iterator;
설명
이 형식은 제어되는 시퀀스에 대한 상수 역방향 반복기로 사용할 수 있는 지정되지 않은 형식 T4 의 개체를 설명합니다.
예제
// cliext_hash_multiset_const_reverse_iterator.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c" reversed
Myhash_multiset::const_reverse_iterator crit = c1.rbegin();
for (; crit != c1.rend(); ++crit)
System::Console::Write("{0} ", *crit);
System::Console::WriteLine();
return (0);
}
c b a
hash_multiset::count(STL/CLR)
지정한 키와 일치하는 요소의 수를 찾습니다.
구문
size_type count(key_type key);
매개 변수
key
검색할 키 값입니다.
설명
멤버 함수는 키와 동등한 순서를 갖는 제어된 시퀀스의 요소 수를 반환합니다. 이를 통해 현재 제어되는 시퀀스에 있는 요소 중 지정된 키와 일치하는 요소의 수를 확인할 수 있습니다.
예제
// cliext_hash_multiset_count.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
System::Console::WriteLine("count(L'A') = {0}", c1.count(L'A'));
System::Console::WriteLine("count(L'b') = {0}", c1.count(L'b'));
System::Console::WriteLine("count(L'C') = {0}", c1.count(L'C'));
return (0);
}
a b c
count(L'A') = 0
count(L'b') = 1
count(L'C') = 0
hash_multiset::difference_type(STL/CLR)
두 요소 사이의 부 서명된 거리 형식입니다.
구문
typedef int difference_type;
설명
이 형식은 음수 요소 수를 설명합니다.
예제
// cliext_hash_multiset_difference_type.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// compute positive difference
Myhash_multiset::difference_type diff = 0;
for (Myhash_multiset::iterator it = c1.begin(); it != c1.end(); ++it)
++diff;
System::Console::WriteLine("end()-begin() = {0}", diff);
// compute negative difference
diff = 0;
for (Myhash_multiset::iterator it = c1.end(); it != c1.begin(); --it)
--diff;
System::Console::WriteLine("begin()-end() = {0}", diff);
return (0);
}
a b c
end()-begin() = 3
begin()-end() = -3
hash_multiset::empty(STL/CLR)
요소가 있는지 여부를 테스트합니다.
구문
bool empty();
설명
멤버 함수는 빈 제어되는 시퀀스에 대해 true를 반환합니다. hash_multiset::size(STL/CLR)() == 0와 동일합니다. hash_multiset 비어 있는지 여부를 테스트하는 데 사용합니다.
예제
// cliext_hash_multiset_empty.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
System::Console::WriteLine("size() = {0}", c1.size());
System::Console::WriteLine("empty() = {0}", c1.empty());
// clear the container and reinspect
c1.clear();
System::Console::WriteLine("size() = {0}", c1.size());
System::Console::WriteLine("empty() = {0}", c1.empty());
return (0);
}
a b c
size() = 3
empty() = False
size() = 0
empty() = True
hash_multiset::end(STL/CLR)
제어되는 시퀀스의 끝을 지정합니다.
구문
iterator end();
설명
멤버 함수는 제어되는 시퀀스의 끝 부분을 가리키는 양방향 반복기를 반환합니다. 제어되는 시퀀스의 끝을 지정하는 반복기를 가져오는 데 사용합니다. 제어되는 시퀀스의 길이가 변경되면 상태가 변경되지 않습니다.
예제
// cliext_hash_multiset_end.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// inspect last two items
Myhash_multiset::iterator it = c1.end();
--it;
System::Console::WriteLine("*-- --end() = {0}", *--it);
System::Console::WriteLine("*--end() = {0}", *++it);
return (0);
}
a b c
*-- --end() = b
*--end() = c
hash_multiset::equal_range(STL/CLR)
지정된 키와 일치하는 범위를 찾습니다.
구문
cliext::pair<iterator, iterator> equal_range(key_type key);
매개 변수
key
검색할 키 값입니다.
설명
멤버 함수는 STL/CLR(STL/CLR)hash_multiset::upper_bound(STL/CLR)(key),hash_multiset::lower_bound 반복(key))기 cliext::pair<iterator, iterator>( 쌍을 반환합니다. 이를 사용하여 지정된 키와 일치하는 제어된 시퀀스에 있는 요소의 범위를 확인합니다.
예제
// cliext_hash_multiset_equal_range.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
typedef Myhash_multiset::pair_iter_iter Pairii;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// display results of failed search
Pairii pair1 = c1.equal_range(L'x');
System::Console::WriteLine("equal_range(L'x') empty = {0}",
pair1.first == pair1.second);
// display results of successful search
pair1 = c1.equal_range(L'b');
for (; pair1.first != pair1.second; ++pair1.first)
System::Console::Write("{0} ", *pair1.first);
System::Console::WriteLine();
return (0);
}
a b c
equal_range(L'x') empty = True
b
hash_multiset::erase(STL/CLR)
지정된 위치에 있는 요소를 제거합니다.
구문
iterator erase(iterator where);
iterator erase(iterator first, iterator last);
bool erase(key_type key)
매개 변수
first
지울 범위의 시작입니다.
key
지울 키 값입니다.
last
지울 범위의 끝입니다.
where
지울 요소입니다.
설명
첫 번째 멤버 함수는 위치가 가리키는 제어되는 시퀀스의 요소를 제거하고 제거된 요소 외에 남아 있는 첫 번째 요소를 지정하는 반복기를 반환하고, 해당 요소가 없으면 hash_multiset::end(STL/CLR)() 를 반환합니다. 단일 요소를 제거하는 데 사용합니다.
두 번째 멤버 함수는 [first, last) 범위에서 제어되는 시퀀스의 요소를 제거하고 제거된 요소 이상으로 남아 있는 첫 번째 요소를 지정하는 반복기를 반환합니다. 그렇지 end() 않으면 해당 요소가 없습니다. 0개 이상의 연속 요소를 제거하는 데 사용합니다.
세 번째 멤버 함수는 키가 키와 동일한 순서를 갖는 제어되는 시퀀스의 모든 요소를 제거하고 제거된 요소 수의 수를 반환합니다. 지정된 키와 일치하는 모든 요소를 제거하고 계산하는 데 사용합니다.
각 요소 지우기에서는 제어되는 시퀀스의 요소 수 로그에 비례하여 시간이 걸립니다.
예제
// cliext_hash_multiset_erase.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// erase an element and reinspect
System::Console::WriteLine("erase(begin()) = {0}",
*c1.erase(c1.begin()));
// add elements and display " b c d e"
c1.insert(L'd');
c1.insert(L'e');
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// erase all but end
Myhash_multiset::iterator it = c1.end();
System::Console::WriteLine("erase(begin(), end()-1) = {0}",
*c1.erase(c1.begin(), --it));
System::Console::WriteLine("size() = {0}", c1.size());
return (0);
}
a b c
erase(begin()) = b
b c d e
erase(begin(), end()-1) = e
size() = 1
hash_multiset::find(STL/CLR)
지정된 키와 일치하는 요소를 찾습니다.
구문
iterator find(key_type key);
매개 변수
key
검색할 키 값입니다.
설명
제어되는 시퀀스에서 하나 이상의 요소에 키가 있는 동일한 순서가 있는 경우 멤버 함수는 해당 요소 중 하나를 지정하는 반복기를 반환합니다. 그렇지 않으면 hash_multiset::end(STL/CLR)()를 반환합니다. 지정된 키와 일치하는 제어된 시퀀스에서 현재 요소를 찾는 데 사용합니다.
예제
// cliext_hash_multiset_find.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
System::Console::WriteLine("find {0} = {1}",
L'A', c1.find(L'A') != c1.end());
System::Console::WriteLine("find {0} = {1}",
L'b', *c1.find(L'b'));
System::Console::WriteLine("find {0} = {1}",
L'C', c1.find(L'C') != c1.end());
return (0);
}
a b c
find A = False
find b = b
find C = False
hash_multiset::generic_container(STL/CLR)
컨테이너에 대한 제네릭 인터페이스의 형식입니다.
구문
typedef Microsoft::VisualC::StlClr::
IHash<GKey, GValue>
generic_container;
설명
이 형식은 이 템플릿 컨테이너 클래스에 대한 제네릭 인터페이스를 설명합니다.
예제
// cliext_hash_multiset_generic_container.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct a generic container
Myhash_multiset::generic_container^ gc1 = %c1;
for each (wchar_t elem in gc1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// modify generic and display original
gc1->insert(L'd');
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// modify original and display generic
c1.insert(L'e');
for each (wchar_t elem in gc1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
return (0);
}
a b c
a b c
a b c d
a b c d e
hash_multiset::generic_iterator(STL/CLR)
컨테이너의 제네릭 인터페이스와 함께 사용할 반복기의 형식입니다.
구문
typedef Microsoft::VisualC::StlClr::Generic::
ContainerBidirectionalIterator<generic_value>
generic_iterator;
설명
이 형식은 이 템플릿 컨테이너 클래스에 대한 제네릭 인터페이스와 함께 사용할 수 있는 제네릭 반복기를 설명합니다.
예제
// cliext_hash_multiset_generic_iterator.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct a generic container
Myhash_multiset::generic_container^ gc1 = %c1;
for each (wchar_t elem in gc1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// get an element and display it
Myhash_multiset::generic_iterator gcit = gc1->begin();
Myhash_multiset::generic_value gcval = *gcit;
System::Console::WriteLine("{0} ", gcval);
return (0);
}
a b c
a b c
a
hash_multiset::generic_reverse_iterator(STL/CLR)
컨테이너의 제네릭 인터페이스와 함께 사용할 역방향 반복기의 형식입니다.
구문
typedef Microsoft::VisualC::StlClr::Generic::
ReverseRandomAccessIterator<generic_value>
generic_reverse_iterator;
설명
이 형식은 이 템플릿 컨테이너 클래스에 대한 제네릭 인터페이스와 함께 사용할 수 있는 제네릭 역방향 반복기를 설명합니다.
예제
// cliext_hash_multiset_generic_reverse_iterator.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct a generic container
Myhash_multiset::generic_container^ gc1 = %c1;
for each (wchar_t elem in gc1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// get an element and display it
Myhash_multiset::generic_reverse_iterator gcit = gc1->rbegin();
Myhash_multiset::generic_value gcval = *gcit;
System::Console::WriteLine("{0} ", gcval);
return (0);
}
a b c
a b c
c
hash_multiset::generic_value(STL/CLR)
컨테이너의 제네릭 인터페이스와 함께 사용할 요소의 형식입니다.
구문
typedef GValue generic_value;
설명
이 형식은 이 템플릿 컨테이너 클래스에 대한 제네릭 인터페이스와 함께 사용할 저장된 요소 값을 설명하는 형식 GValue 의 개체를 설명합니다.
예제
// cliext_hash_multiset_generic_value.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct a generic container
Myhash_multiset::generic_container^ gc1 = %c1;
for each (wchar_t elem in gc1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// get an element and display it
Myhash_multiset::generic_iterator gcit = gc1->begin();
Myhash_multiset::generic_value gcval = *gcit;
System::Console::WriteLine("{0} ", gcval);
return (0);
}
a b c
a b c
a
hash_multiset::hash_delegate(STL/CLR)
지정된 키와 일치하는 요소를 찾습니다.
구문
hasher^ hash_delegate();
설명
멤버 함수는 키 값을 정수로 변환하는 데 사용되는 대리자를 반환합니다. 키를 해시하는 데 사용합니다.
예제
// cliext_hash_multiset_hash_delegate.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
Myhash_multiset::hasher^ myhash = c1.hash_delegate();
System::Console::WriteLine("hash(L'a') = {0}", myhash(L'a'));
System::Console::WriteLine("hash(L'b') = {0}", myhash(L'b'));
return (0);
}
hash(L'a') = 1616896120
hash(L'b') = 570892832
hash_multiset::hash_multiset(STL/CLR)
컨테이너 개체를 만듭니다.
구문
hash_multiset();
explicit hash_multiset(key_compare^ pred);
hash_multiset(key_compare^ pred, hasher^ hashfn);
hash_multiset(hash_multiset<Key>% right);
hash_multiset(hash_multiset<Key>^ right);
template<typename InIter>
hash_multiset(InIter first, InIter last);
template<typename InIter>
hash_multiset(InIter first, InIter last,
key_compare^ pred);
template<typename InIter>
hash_multiset(InIter first, InIter last,
key_compare^ pred, hasher^ hashfn);
hash_multiset(System::Collections::Generic::IEnumerable<GValue>^ right);
hash_multiset(System::Collections::Generic::IEnumerable<GValue>^ right,
key_compare^ pred);
hash_multiset(System::Collections::Generic::IEnumerable<GValue>^ right,
key_compare^ pred, hasher^ hashfn);
매개 변수
first
삽입할 범위의 시작입니다.
hashfn
버킷에 키를 매핑하는 해시 함수입니다.
last
삽입할 범위의 끝입니다.
Pred
제어되는 시퀀스에 대한 조건자 순서 지정
right
삽입할 개체 또는 범위입니다.
설명
생성자:
hash_multiset();
는 기본 순서 조건 key_compare()자 및 기본 해시 함수를 사용하여 요소가 없는 제어되는 시퀀스를 초기화합니다. 기본 순서 조건자 및 해시 함수를 사용하여 빈 초기 제어 시퀀스를 지정하는 데 사용합니다.
생성자:
explicit hash_multiset(key_compare^ pred);
는 요소 없이, 정렬 조건자가 미리 지정되고, 기본 해시 함수를 사용하여 제어되는 시퀀스를 초기화합니다. 지정된 순서 조건자와 기본 해시 함수를 사용하여 빈 초기 제어 시퀀스를 지정하는 데 사용합니다.
생성자:
hash_multiset(key_compare^ pred, hasher^ hashfn);
는 요소 없이, 정렬 조건자가 미리 지정되고, 해시 함수 해시프n을 사용하여 제어되는 시퀀스를 초기화합니다. 지정된 순서 조건자 및 해시 함수를 사용하여 빈 초기 제어 시퀀스를 지정하는 데 사용합니다.
생성자:
hash_multiset(hash_multiset<Key>% right);
시퀀스 [right.begin(), right.end()), 기본 순서 조건자 및 기본 해시 함수를 사용하여 제어되는 시퀀스를 초기화합니다. 기본 순서 조건자 및 해시 함수를 사용하여 hash_multiset 개체 오른쪽에 의해 제어되는 시퀀스의 복사본인 초기 제어 시퀀스를 지정하는 데 사용합니다.
생성자:
hash_multiset(hash_multiset<Key>^ right);
시퀀스 [right->begin(), right->end()), 기본 순서 조건자 및 기본 해시 함수를 사용하여 제어되는 시퀀스를 초기화합니다. 기본 순서 조건자 및 해시 함수를 사용하여 hash_multiset 개체 오른쪽에 의해 제어되는 시퀀스의 복사본인 초기 제어 시퀀스를 지정하는 데 사용합니다.
생성자:
template<typename InIter> hash_multiset(InIter first, InIter last);
시퀀스 [first, last), 기본 순서 조건자 및 기본 해시 함수를 사용하여 제어되는 시퀀스를 초기화합니다. 이를 사용하여 제어된 시퀀스를 기본 순서 조건자 및 해시 함수를 사용하여 다른 시퀀스의 복사본으로 만듭니다.
생성자:
template<typename InIter> hash_multiset(InIter first, InIter last, key_compare^ pred);
순서 지정 조건자를 미리 지정하고 기본 해시 함수를 사용하여 [, last) 시퀀스를first 사용하여 제어되는 시퀀스를 초기화합니다. 지정된 순서 조건자와 기본 해시 함수를 사용하여 제어되는 시퀀스를 다른 시퀀스의 복사본으로 만드는 데 사용합니다.
생성자:
template<typename InIter> hash_multiset(InIter first, InIter last, key_compare^ pred, hasher^ hashfn);
순서 지정 조건자가 미리 지정된 시퀀스 [first, last), 해시 함수 해시fn을 사용하여 제어되는 시퀀스를 초기화합니다. 지정된 순서 조건자 및 해시 함수를 사용하여 제어되는 시퀀스를 다른 시퀀스의 복사본으로 만드는 데 사용합니다.
생성자:
hash_multiset(System::Collections::Generic::IEnumerable<Key>^ right);
는 기본 순서 조건자 및 기본 해시 함수를 사용하여 열거자 권한으로 지정된 시퀀스를 사용하여 제어되는 시퀀스를 초기화합니다. 제어된 시퀀스를 기본 순서 조건자 및 해시 함수를 사용하여 열거자가 설명하는 다른 시퀀스의 복사본으로 만드는 데 사용합니다.
생성자:
hash_multiset(System::Collections::Generic::IEnumerable<Key>^ right, key_compare^ pred);
는 순서 지정 조건자를 미리 지정하고 기본 해시 함수를 사용하여 열거자 권한으로 지정된 시퀀스를 사용하여 제어 되는 시퀀스를 초기화합니다. 제어된 시퀀스를 지정된 순서 조건자 및 기본 해시 함수를 사용하여 열거자가 설명하는 다른 시퀀스의 복사본으로 만드는 데 사용합니다.
생성자:
hash_multiset(System::Collections::Generic::IEnumerable<Key>^ right, key_compare^ pred, hasher^ hashfn);
는 순서 지정 조건자를 미리 지정하고 해시 함수 해시프n을 사용하여 열거자 오른쪽에 지정된 시퀀스를 사용하여 제어되는 시퀀스를 초기화합니다. 제어된 시퀀스를 지정된 순서 지정 조건자 및 해시 함수를 사용하여 열거자가 설명하는 다른 시퀀스의 복사본으로 만드는 데 사용합니다.
예제
// cliext_hash_multiset_construct.cpp
// compile with: /clr
#include <cliext/hash_set>
int myfun(wchar_t key)
{ // hash a key
return (key ^ 0xdeadbeef);
}
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
// construct an empty container
Myhash_multiset c1;
System::Console::WriteLine("size() = {0}", c1.size());
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct with an ordering rule
Myhash_multiset c2 = cliext::greater_equal<wchar_t>();
System::Console::WriteLine("size() = {0}", c2.size());
c2.insert(c1.begin(), c1.end());
for each (wchar_t elem in c2)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct with an ordering rule and hash function
Myhash_multiset c2h(cliext::greater_equal<wchar_t>(),
gcnew Myhash_multiset::hasher(&myfun));
System::Console::WriteLine("size() = {0}", c2h.size());
c2h.insert(c1.begin(), c1.end());
for each (wchar_t elem in c2h)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
System::Console::WriteLine();
// construct with an iterator range
Myhash_multiset c3(c1.begin(), c1.end());
for each (wchar_t elem in c3)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct with an iterator range and an ordering rule
Myhash_multiset c4(c1.begin(), c1.end(),
cliext::greater_equal<wchar_t>());
for each (wchar_t elem in c4)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct with an iterator range and an ordering rule and hash function
Myhash_multiset c4h(c1.begin(), c1.end(),
cliext::greater_equal<wchar_t>(),
gcnew Myhash_multiset::hasher(&myfun));
for each (wchar_t elem in c4h)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
System::Console::WriteLine();
// construct with an enumeration
Myhash_multiset c5( // NOTE: cast is not needed
(System::Collections::Generic::IEnumerable<wchar_t>^)%c3);
for each (wchar_t elem in c5)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct with an enumeration and an ordering rule
Myhash_multiset c6( // NOTE: cast is not needed
(System::Collections::Generic::IEnumerable<wchar_t>^)%c3,
cliext::greater_equal<wchar_t>());
for each (wchar_t elem in c6)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct with an enumeration and an ordering rule and hash function
Myhash_multiset c6h( // NOTE: cast is not needed
(System::Collections::Generic::IEnumerable<wchar_t>^)%c3,
cliext::greater_equal<wchar_t>(),
gcnew Myhash_multiset::hasher(&myfun));
for each (wchar_t elem in c6h)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
System::Console::WriteLine();
// construct from a generic container
Myhash_multiset c7(c4);
for each (wchar_t elem in c7)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct by copying another container
Myhash_multiset c8(%c3);
for each (wchar_t elem in c8)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
return (0);
}
size() = 0
a b c
size() = 0
a b c
size() = 0
c b a
a b c
a b c
c b a
a b c
a b c
c b a
a b c
a b c
hash_multiset::hasher(STL/CLR)
키에 대한 해시 대리자입니다.
구문
Microsoft::VisualC::StlClr::UnaryDelegate<GKey, int>
hasher;
설명
이 형식은 키 값을 정수로 변환하는 대리자를 설명합니다.
예제
// cliext_hash_multiset_hasher.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
Myhash_multiset::hasher^ myhash = c1.hash_delegate();
System::Console::WriteLine("hash(L'a') = {0}", myhash(L'a'));
System::Console::WriteLine("hash(L'b') = {0}", myhash(L'b'));
return (0);
}
hash(L'a') = 1616896120
hash(L'b') = 570892832
hash_multiset::insert(STL/CLR)
요소를 추가합니다.
구문
iterator insert(value_type val);
iterator insert(iterator where, value_type val);
template<typename InIter>
void insert(InIter first, InIter last);
void insert(System::Collections::Generic::IEnumerable<value_type>^ right);
매개 변수
first
삽입할 범위의 시작입니다.
last
삽입할 범위의 끝입니다.
right
삽입할 열거형입니다.
발
삽입할 키 값입니다.
where
컨테이너에서 삽입할 위치(힌트만 해당).
설명
각 멤버 함수는 나머지 피연산자가 지정한 시퀀스를 삽입합니다.
첫 번째 멤버 함수는 값 val이 있는 요소를 삽입하고 새로 삽입된 요소를 지정하는 반복기를 반환합니다. 단일 요소를 삽입하는 데 사용합니다.
두 번째 멤버 함수는 where를 힌트로 사용하여 값 val이 있는 요소를 삽입하고 새로 삽입된 요소를 지정하는 반복기를 반환합니다. 이를 사용하여 알고 있는 요소에 인접할 수 있는 단일 요소를 삽입합니다.
세 번째 멤버 함수는 시퀀스 [, last)를first 삽입합니다. 다른 시퀀스에서 복사한 요소를 0개 이상 삽입하는 데 사용합니다.
네 번째 멤버 함수는 오른쪽에 지정된 시퀀스를 삽입합니다. 열거자가 설명하는 시퀀스를 삽입하는 데 사용합니다.
각 요소 삽입은 제어되는 시퀀스의 요소 수 로그에 비례하여 시간이 걸립니다. 그러나 삽입 지점에 인접한 요소를 지정하는 힌트가 제공되면 분할 상환 상수 시간에 삽입이 발생할 수 있습니다.
예제
// cliext_hash_multiset_insert.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// insert a single value, unique and duplicate
System::Console::WriteLine("insert(L'x') = {0}",
*c1.insert(L'x'));
System::Console::WriteLine("insert(L'b') = {0}",
*c1.insert(L'b'));
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// insert a single value with hint
System::Console::WriteLine("insert(begin(), L'y') = {0}",
*c1.insert(c1.begin(), L'y'));
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// insert an iterator range
Myhash_multiset c2;
Myhash_multiset::iterator it = c1.end();
c2.insert(c1.begin(), --it);
for each (wchar_t elem in c2)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// insert an enumeration
Myhash_multiset c3;
c3.insert( // NOTE: cast is not needed
(System::Collections::Generic::IEnumerable<wchar_t>^)%c1);
for each (wchar_t elem in c3)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
return (0);
}
a b c
insert(L'x') = x
insert(L'b') = b
a b b c x
insert(begin(), L'y') = y
a b b c x y
a b b c x
a b b c x y
hash_multiset::iterator(STL/CLR)
제어되는 시퀀스에 대한 반복기의 형식입니다.
구문
typedef T1 iterator;
설명
이 형식은 제어되는 시퀀스에 대한 양방향 반복기 역할을 할 수 있는 지정되지 않은 형식 T1 의 개체를 설명합니다.
예제
// cliext_hash_multiset_iterator.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c"
Myhash_multiset::iterator it = c1.begin();
for (; it != c1.end(); ++it)
System::Console::Write("{0} ", *it);
System::Console::WriteLine();
return (0);
}
a b c
hash_multiset::key_comp(STL/CLR)
두 키에 대한 순서 지정 대리자를 복사합니다.
구문
key_compare^key_comp();
설명
멤버 함수는 제어되는 시퀀스를 정렬하는 데 사용되는 순서 지정 대리자를 반환합니다. 이를 통해 두 키를 비교할 수 있습니다.
예제
// cliext_hash_multiset_key_comp.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
Myhash_multiset::key_compare^ kcomp = c1.key_comp();
System::Console::WriteLine("compare(L'a', L'a') = {0}",
kcomp(L'a', L'a'));
System::Console::WriteLine("compare(L'a', L'b') = {0}",
kcomp(L'a', L'b'));
System::Console::WriteLine("compare(L'b', L'a') = {0}",
kcomp(L'b', L'a'));
System::Console::WriteLine();
// test a different ordering rule
Myhash_multiset c2 = cliext::greater<wchar_t>();
kcomp = c2.key_comp();
System::Console::WriteLine("compare(L'a', L'a') = {0}",
kcomp(L'a', L'a'));
System::Console::WriteLine("compare(L'a', L'b') = {0}",
kcomp(L'a', L'b'));
System::Console::WriteLine("compare(L'b', L'a') = {0}",
kcomp(L'b', L'a'));
return (0);
}
compare(L'a', L'a') = True
compare(L'a', L'b') = True
compare(L'b', L'a') = False
compare(L'a', L'a') = False
compare(L'a', L'b') = False
compare(L'b', L'a') = True
hash_multiset::key_compare(STL/CLR)
두 키에 대한 순서 지정 대리자입니다.
구문
Microsoft::VisualC::StlClr::BinaryDelegate<GKey, GKey, bool>
key_compare;
설명
형식은 키 인수의 순서를 결정하는 대리자의 동의어입니다.
예제
// cliext_hash_multiset_key_compare.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
Myhash_multiset::key_compare^ kcomp = c1.key_comp();
System::Console::WriteLine("compare(L'a', L'a') = {0}",
kcomp(L'a', L'a'));
System::Console::WriteLine("compare(L'a', L'b') = {0}",
kcomp(L'a', L'b'));
System::Console::WriteLine("compare(L'b', L'a') = {0}",
kcomp(L'b', L'a'));
System::Console::WriteLine();
// test a different ordering rule
Myhash_multiset c2 = cliext::greater<wchar_t>();
kcomp = c2.key_comp();
System::Console::WriteLine("compare(L'a', L'a') = {0}",
kcomp(L'a', L'a'));
System::Console::WriteLine("compare(L'a', L'b') = {0}",
kcomp(L'a', L'b'));
System::Console::WriteLine("compare(L'b', L'a') = {0}",
kcomp(L'b', L'a'));
return (0);
}
compare(L'a', L'a') = True
compare(L'a', L'b') = True
compare(L'b', L'a') = False
compare(L'a', L'a') = False
compare(L'a', L'b') = False
compare(L'b', L'a') = True
hash_multiset::key_type(STL/CLR)
정렬 키의 형식입니다.
구문
typedef Key key_type;
설명
형식은 템플릿 매개 변수 키의 동의어입니다.
예제
// cliext_hash_multiset_key_type.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c" using key_type
for (Myhash_multiset::iterator it = c1.begin(); it != c1.end(); ++it)
{ // store element in key_type object
Myhash_multiset::key_type val = *it;
System::Console::Write("{0} ", val);
}
System::Console::WriteLine();
return (0);
}
a b c
hash_multiset::load_factor(STL/CLR)
버킷당 평균 요소 수를 계산합니다.
구문
float load_factor();
설명
멤버 함수는 hash_multiset::size(STL/CLR)() /hash_multiset::bucket_count(STL/CLR)를 반환 (float) 합니다(). 이를 사용하여 평균 버킷 크기를 결정합니다.
예제
// cliext_hash_multiset_load_factor.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// inspect current parameters
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
System::Console::WriteLine();
// change max_load_factor and redisplay
c1.max_load_factor(0.25f);
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
System::Console::WriteLine();
// rehash and redisplay
c1.rehash(100);
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
return (0);
}
a b c
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25
bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25
hash_multiset::lower_bound(STL/CLR)
지정된 키와 일치하는 범위의 시작을 찾습니다.
구문
iterator lower_bound(key_type key);
매개 변수
key
검색할 키 값입니다.
설명
멤버 함수는 키와 동일한 버킷에 해시하고 키에 대한 동일한 순서를 포함하는 제어되는 시퀀스의 첫 번째 요소를 X 결정합니다. 이러한 요소가 없으면 hash_multiset::end(STL/CLR)()를 반환하고, 그렇지 않으면 지정하는 반복기를 반환합니다 X. 이를 사용하여 지정된 키와 일치하는 제어된 시퀀스에서 현재 요소 시퀀스의 시작을 찾습니다.
예제
// cliext_hash_multiset_lower_bound.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
System::Console::WriteLine("lower_bound(L'x')==end() = {0}",
c1.lower_bound(L'x') == c1.end());
System::Console::WriteLine("*lower_bound(L'a') = {0}",
*c1.lower_bound(L'a'));
System::Console::WriteLine("*lower_bound(L'b') = {0}",
*c1.lower_bound(L'b'));
return (0);
}
a b c
lower_bound(L'x')==end() = True
*lower_bound(L'a') = a
*lower_bound(L'b') = b
hash_multiset::make_value(STL/CLR)
값 개체를 생성합니다.
구문
static value_type make_value(key_type key);
매개 변수
key
사용할 키 값입니다.
설명
멤버 함수는 키가 키인 value_type 개체를 반환합니다. 다른 여러 멤버 함수와 함께 사용하기에 적합한 개체를 구성하는 데 사용합니다.
예제
// cliext_hash_multiset_make_value.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(Myhash_multiset::make_value(L'a'));
c1.insert(Myhash_multiset::make_value(L'b'));
c1.insert(Myhash_multiset::make_value(L'c'));
// display contents " a b c"
for each (Myhash_multiset::value_type elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
return (0);
}
a b c
hash_multiset::max_load_factor(STL/CLR)
버킷당 최대 요소 수를 가져오거나 설정합니다.
구문
float max_load_factor();
void max_load_factor(float new_factor);
매개 변수
new_factor
저장할 새 최대 로드 팩터입니다.
설명
첫 번째 멤버 함수는 현재 저장된 최대 로드 요소를 반환합니다. 이를 사용하여 최대 평균 버킷 크기를 결정합니다.
두 번째 멤버 함수는 저장소 최대 로드 요소를 new_factor 바꿉니다. 후속 삽입까지 자동 다시 해시가 발생하지 않습니다.
예제
// cliext_hash_multiset_max_load_factor.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// inspect current parameters
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
System::Console::WriteLine();
// change max_load_factor and redisplay
c1.max_load_factor(0.25f);
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
System::Console::WriteLine();
// rehash and redisplay
c1.rehash(100);
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
return (0);
}
a b c
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25
bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25
hash_multiset::operator=(STL/CLR)
제어되는 시퀀스를 바꿉니다.
구문
hash_multiset<Key>% operator=(hash_multiset<Key>% right);
매개 변수
right
복사할 컨테이너입니다.
설명
멤버 연산자는 개체에 바로 복사한 다음 반환합니다 *this. 제어되는 시퀀스를 제어되는 시퀀스의 복사본으로 오른쪽에 바꾸는 데 사용합니다.
예제
// cliext_hash_multiset_operator_as.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c"
for each (Myhash_multiset::value_type elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// assign to a new container
Myhash_multiset c2;
c2 = c1;
// display contents " a b c"
for each (Myhash_multiset::value_type elem in c2)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
return (0);
}
a b c
a b c
hash_multiset::rbegin(STL/CLR)
제어되는 역방향 시퀀스의 시작을 지정합니다.
구문
reverse_iterator rbegin();
설명
멤버 함수는 제어되는 시퀀스의 마지막 요소를 지정하거나 빈 시퀀스의 시작 부분 바로 너머를 지정하는 역방향 반복기를 반환합니다. 따라서 역방향 시퀀스의 beginning을 지정합니다. 이를 통해 역순으로 표시된 제어되는 시퀀스의 current 시작을 지정하는 반복기를 가져올 수 있지만 제어되는 시퀀스의 길이가 변경되면 상태가 변경될 수 있습니다.
예제
// cliext_hash_multiset_rbegin.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// inspect first two items in reversed sequence
Myhash_multiset::reverse_iterator rit = c1.rbegin();
System::Console::WriteLine("*rbegin() = {0}", *rit);
System::Console::WriteLine("*++rbegin() = {0}", *++rit);
return (0);
}
a b c
*rbegin() = c
*++rbegin() = b
hash_multiset::reference(STL/CLR)
요소에 대한 참조의 형식입니다.
구문
typedef value_type% reference;
설명
이 형식은 요소에 대한 참조를 설명합니다.
예제
// cliext_hash_multiset_reference.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
Myhash_multiset::iterator it = c1.begin();
for (; it != c1.end(); ++it)
{ // get a reference to an element
Myhash_multiset::reference ref = *it;
System::Console::Write("{0} ", ref);
}
System::Console::WriteLine();
return (0);
}
a b c
hash_multiset::rehash(STL/CLR)
해시 테이블을 다시 빌드합니다.
구문
void rehash();
설명
멤버 함수는 해시 테이블을 다시 빌드하여 hash_multiset::load_factor(STL/CLR)() <=hash_multiset::max_load_factor(STL/CLR)를 확인합니다. 그렇지 않으면 삽입 후에 필요에 따라 해시 테이블의 크기가 증가합니다. (크기는 자동으로 감소하지 않습니다.) 해시 테이블의 크기를 조정하는 데 사용합니다.
예제
// cliext_hash_multiset_rehash.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// inspect current parameters
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
System::Console::WriteLine();
// change max_load_factor and redisplay
c1.max_load_factor(0.25f);
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
System::Console::WriteLine();
// rehash and redisplay
c1.rehash(100);
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
return (0);
}
a b c
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 4
bucket_count() = 16
load_factor() = 0.1875
max_load_factor() = 0.25
bucket_count() = 128
load_factor() = 0.0234375
max_load_factor() = 0.25
hash_multiset::rend(STL/CLR)
제어되는 역방향 시퀀스의 끝을 지정합니다.
구문
reverse_iterator rend();
설명
멤버 함수는 제어되는 시퀀스의 시작 부분 바로 앞을 가리키는 역방향 반복기를 반환합니다. 따라서 역방향 시퀀스의 end을 지정합니다. 이를 통해 역순으로 표시된 제어되는 시퀀스의 current 끝을 지정하는 반복기를 가져올 수 있지만 제어되는 시퀀스의 길이가 변경되면 상태가 변경될 수 있습니다.
예제
// cliext_hash_multiset_rend.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// inspect first two items
Myhash_multiset::reverse_iterator rit = c1.rend();
--rit;
System::Console::WriteLine("*-- --rend() = {0}", *--rit);
System::Console::WriteLine("*--rend() = {0}", *++rit);
return (0);
}
a b c
*-- --rend() = b
*--rend() = a
hash_multiset::reverse_iterator(STL/CLR)
제어되는 시퀀스에 대한 반대 반복기의 형식입니다.
구문
typedef T3 reverse_iterator;
설명
이 형식은 제어된 시퀀스에 대해 반대 반복기로 사용될 수 있는 지정되지 않은 T3 형식의 개체를 설명합니다.
예제
// cliext_hash_multiset_reverse_iterator.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c" reversed
Myhash_multiset::reverse_iterator rit = c1.rbegin();
for (; rit != c1.rend(); ++rit)
System::Console::Write("{0} ", *rit);
System::Console::WriteLine();
return (0);
}
c b a
hash_multiset::size(STL/CLR)
요소 수를 계산합니다.
구문
size_type size();
설명
멤버 함수는 제어되는 시퀀스의 길이를 반환합니다. 이를 사용하여 현재 제어되는 시퀀스에 있는 요소 수를 확인합니다. 시퀀스의 크기가 0이 아닌 경우 hash_multiset::empty(STL/CLR)()를 참조하세요.
예제
// cliext_hash_multiset_size.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
System::Console::WriteLine("size() = {0} starting with 3", c1.size());
// clear the container and reinspect
c1.clear();
System::Console::WriteLine("size() = {0} after clearing", c1.size());
// add elements and clear again
c1.insert(L'a');
c1.insert(L'b');
System::Console::WriteLine("size() = {0} after adding 2", c1.size());
return (0);
}
a b c
size() = 3 starting with 3
size() = 0 after clearing
size() = 2 after adding 2
hash_multiset::size_type(STL/CLR)
두 요소 사이의 부 서명된 거리의 형식입니다.
구문
typedef int size_type;
설명
이 형식은 음수가 아닌 요소 수를 설명합니다.
예제
// cliext_hash_multiset_size_type.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// compute positive difference
Myhash_multiset::size_type diff = 0;
for (Myhash_multiset::iterator it = c1.begin(); it != c1.end(); ++it)
++diff;
System::Console::WriteLine("end()-begin() = {0}", diff);
return (0);
}
a b c
end()-begin() = 3
hash_multiset::swap(STL/CLR)
두 컨테이너의 내용을 바꿉니다.
구문
void swap(hash_multiset<Key>% right);
매개 변수
right
콘텐츠와 바꿀 컨테이너입니다.
설명
멤버 함수는 제어된 시퀀스를 오른쪽 간에 this 교환합니다. 그것은 일정한 시간에 그렇게하고 예외를 throw하지 않습니다. 두 컨테이너의 콘텐츠를 빠르게 교환하는 방법으로 사용합니다.
예제
// cliext_hash_multiset_swap.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct another container with repetition of values
Myhash_multiset c2;
c2.insert(L'd');
c2.insert(L'e');
c2.insert(L'f');
for each (wchar_t elem in c2)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// swap and redisplay
c1.swap(c2);
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
for each (wchar_t elem in c2)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
return (0);
}
a b c
d e f
d e f
a b c
hash_multiset::to_array(STL/CLR)
제어된 시퀀스를 새 배열에 복사합니다.
구문
cli::array<value_type>^ to_array();
설명
멤버 함수는 제어되는 시퀀스를 포함하는 배열을 반환합니다. 이를 사용하여 배열 형식으로 제어되는 시퀀스의 복사본을 가져옵니다.
예제
// cliext_hash_multiset_to_array.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// copy the container and modify it
cli::array<wchar_t>^ a1 = c1.to_array();
c1.insert(L'd');
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// display the earlier array copy
for each (wchar_t elem in a1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
return (0);
}
a b c d
a b c
hash_multiset::upper_bound(STL/CLR)
지정된 키와 일치하는 범위의 끝을 찾습니다.
구문
iterator upper_bound(key_type key);
매개 변수
key
검색할 키 값입니다.
설명
멤버 함수는 키와 동일한 버킷에 해시하고 키에 대한 동일한 순서를 포함하는 제어되는 시퀀스의 마지막 요소를 X 결정합니다. 이러한 요소가 없거나 제어된 시퀀스의 마지막 요소인 경우 Xhash_multiset::end(STL/CLR)()를 반환합니다. 그렇지 않으면 첫 번째 요소를 초과하는 X요소를 지정하는 반복기를 반환합니다. 지정된 키와 일치하는 제어된 시퀀스에서 현재 요소 시퀀스의 끝을 찾는 데 사용합니다.
예제
// cliext_hash_multiset_upper_bound.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
System::Console::WriteLine("upper_bound(L'x')==end() = {0}",
c1.upper_bound(L'x') == c1.end());
System::Console::WriteLine("*upper_bound(L'a') = {0}",
*c1.upper_bound(L'a'));
System::Console::WriteLine("*upper_bound(L'b') = {0}",
*c1.upper_bound(L'b'));
return (0);
}
a b c
upper_bound(L'x')==end() = True
*upper_bound(L'a') = b
*upper_bound(L'b') = c
hash_multiset::value_comp(STL/CLR)
두 요소 값에 대한 순서 지정 대리자를 복사합니다.
구문
value_compare^ value_comp();
설명
멤버 함수는 제어되는 시퀀스를 정렬하는 데 사용되는 순서 지정 대리자를 반환합니다. 두 요소 값을 비교하는 데 사용합니다.
예제
// cliext_hash_multiset_value_comp.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
Myhash_multiset::value_compare^ kcomp = c1.value_comp();
System::Console::WriteLine("compare(L'a', L'a') = {0}",
kcomp(L'a', L'a'));
System::Console::WriteLine("compare(L'a', L'b') = {0}",
kcomp(L'a', L'b'));
System::Console::WriteLine("compare(L'b', L'a') = {0}",
kcomp(L'b', L'a'));
System::Console::WriteLine();
return (0);
}
compare(L'a', L'a') = True
compare(L'a', L'b') = True
compare(L'b', L'a') = False
hash_multiset::value_compare(STL/CLR)
두 요소 값의 순서 지정 대리자입니다.
구문
Microsoft::VisualC::StlClr::BinaryDelegate<generic_value, generic_value, bool>
value_compare;
설명
형식은 해당 값 인수의 순서를 결정하는 대리자의 동의어입니다.
예제
// cliext_hash_multiset_value_compare.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
Myhash_multiset::value_compare^ kcomp = c1.value_comp();
System::Console::WriteLine("compare(L'a', L'a') = {0}",
kcomp(L'a', L'a'));
System::Console::WriteLine("compare(L'a', L'b') = {0}",
kcomp(L'a', L'b'));
System::Console::WriteLine("compare(L'b', L'a') = {0}",
kcomp(L'b', L'a'));
System::Console::WriteLine();
return (0);
}
compare(L'a', L'a') = True
compare(L'a', L'b') = True
compare(L'b', L'a') = False
hash_multiset::value_type(STL/CLR)
요소의 형식입니다.
구문
typedef generic_value value_type;
설명
이 형식은 generic_value의 동의어입니다.
예제
// cliext_hash_multiset_value_type.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;
int main()
{
Myhash_multiset c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display contents " a b c" using value_type
for (Myhash_multiset::iterator it = c1.begin(); it != c1.end(); ++it)
{ // store element in value_type object
Myhash_multiset::value_type val = *it;
System::Console::Write("{0} ", val);
}
System::Console::WriteLine();
return (0);
}
a b c