// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH11_AssociativeContainers/examples/setOps.cc
// Function: main
int main()
{
	// define a vector with 20 elements,
	// holding two copies of each number from 0 to 9
	vector<int> ivec;
	for (vector<int>::size_type i = 10; i != 0; --i) {
		ivec.push_back(i);
		ivec.push_back(i);  // duplicate copies of each number
	}

	// iset holds unique elements from ivec; miset holds all 20 elements
	set<int> iset(ivec.cbegin(), ivec.cend());
	multiset<int> miset(ivec.cbegin(), ivec.cend());

	cout << ivec.size() << endl;    // prints 20
	cout << iset.size() << endl;    // prints 10
	for (const auto item : iset)
		cout << item << endl;

	cout << miset.size() << endl;   // prints 20

	// returns an iterator that refers to the element with key == 1
	iset.find(1);
	iset.find(11);  // returns the iterator == iset.end()
	iset.count(1);  // returns 1
	iset.count(11); // returns 0

	// returns an iterator to the first element with key == 1
	iset.find(1);
	iset.find(11);   // returns the iterator == iset.end()
	miset.count(1);  // returns 2
	miset.count(11); // returns 0

	set<string> set1;    // empty set
	set1.insert("the");  // set1 now has one element
	set1.insert("and");  // set1 now has two elements

	ivec = {2,4,6,8,2,4,6,8}; // ivec now has eight elements
	set<int> set2;            // empty set
	set2.insert(ivec.cbegin(), ivec.cend()); // set2 has four elements
	set2.insert({1,3,5,7,1,3,5,7});      // set2 now has eight elements
	for (const auto item : set2)
		cout << item << endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rbx
andq $0x0, 0x10(%rbx)
movaps %xmm0, (%rbx)
pushq $0xa
popq %r12
leaq -0xa0(%rbp), %r14
movq %r12, %r15
subq $0x1, %r15
jb 0x132a
movl %r12d, -0xa0(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x186e
movl %r12d, -0xa0(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x186e
movq %r15, %r12
jmp 0x12fb
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
callq 0x169e
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x120(%rbp), %rdi
callq 0x16e2
movq -0x38(%rbp), %rsi
subq -0x40(%rbp), %rsi
sarq $0x2, %rsi
movq 0x3c73(%rip), %rdi      # 0x4fd8
callq 0x10c0
movq %rax, %rdi
callq 0x10a0
movq -0x78(%rbp), %rsi
movq 0x3c5b(%rip), %rdi      # 0x4fd8
callq 0x10c0
movq %rax, %rdi
callq 0x10a0
leaq -0x98(%rbp), %r15
movq 0x10(%r15), %r14
movq 0x3c3c(%rip), %rbx      # 0x4fd8
cmpq %r15, %r14
je 0x13c2
movl 0x20(%r14), %esi
movq %rbx, %rdi
callq 0x1170
movq %rax, %rdi
callq 0x10a0
movq %r14, %rdi
callq 0x1130
movq %rax, %r14
jmp 0x139c
movq -0xf8(%rbp), %rsi
movq 0x3c08(%rip), %rdi      # 0x4fd8
callq 0x10c0
movq %rax, %rdi
callq 0x10a0
leaq -0xd0(%rbp), %rsi
movl $0x1, (%rsi)
leaq -0xa0(%rbp), %rdi
callq 0x1ea0
leaq -0xd0(%rbp), %rsi
movl $0xb, (%rsi)
leaq -0xa0(%rbp), %rdi
callq 0x1ea0
leaq -0xd0(%rbp), %rsi
movl $0x1, (%rsi)
leaq -0xa0(%rbp), %rdi
callq 0x1726
leaq -0xd0(%rbp), %rsi
movl $0xb, (%rsi)
leaq -0xa0(%rbp), %rdi
callq 0x1726
leaq -0xd0(%rbp), %rsi
movl $0x1, (%rsi)
leaq -0xa0(%rbp), %rdi
callq 0x1ea0
leaq -0xd0(%rbp), %rsi
movl $0xb, (%rsi)
leaq -0xa0(%rbp), %rdi
callq 0x1ea0
leaq -0xd0(%rbp), %rsi
movl $0x1, (%rsi)
leaq -0x120(%rbp), %rdi
callq 0x1f50
leaq -0xd0(%rbp), %rsi
movl $0xb, (%rsi)
leaq -0x120(%rbp), %rdi
callq 0x1f50
leaq -0xc8(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x1b3c(%rip), %rsi      # 0x3004
leaq -0x70(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
callq 0x1070
leaq -0xd0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x2040
leaq -0x70(%rbp), %rdi
callq 0x1090
leaq 0x1b10(%rip), %rsi      # 0x3008
leaq -0x70(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
callq 0x1070
leaq -0xd0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x2040
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
callq 0x1090
movups 0x1b3d(%rip), %xmm0     # 0x3068
movaps %xmm0, 0x10(%rbx)
movups 0x1b22(%rip), %xmm0     # 0x3058
movaps %xmm0, (%rbx)
leaq -0x50(%rbp), %rdx
leaq -0x40(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x2218
leaq -0x68(%rbp), %r15
andl $0x0, (%r15)
andq $0x0, 0x8(%r15)
movq %r15, 0x10(%r15)
movq %r15, 0x18(%r15)
andq $0x0, 0x20(%r15)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x19ee
movups 0x1b0c(%rip), %xmm0     # 0x3088
leaq -0xd0(%rbp), %rdx
movaps %xmm0, -0x10(%rdx)
movups 0x1aea(%rip), %xmm0     # 0x3078
movaps %xmm0, -0x20(%rdx)
leaq -0x70(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x2358
movq -0x58(%rbp), %r14
movq 0x3a2b(%rip), %rbx      # 0x4fd8
cmpq %r15, %r14
je 0x15d3
movl 0x20(%r14), %esi
movq %rbx, %rdi
callq 0x1170
movq %rax, %rdi
callq 0x10a0
movq %r14, %rdi
callq 0x1130
movq %rax, %r14
jmp 0x15ad
leaq -0x70(%rbp), %rdi
callq 0x1758
leaq -0xd0(%rbp), %rdi
callq 0x17b4
leaq -0x120(%rbp), %rdi
callq 0x1758
leaq -0xa0(%rbp), %rdi
callq 0x1758
leaq -0x40(%rbp), %rdi
callq 0x1830
xorl %eax, %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1658
jmp 0x1658
jmp 0x1633
jmp 0x1625
jmp 0x1633
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x1090
jmp 0x1664
movq %rax, %rbx
jmp 0x1664
jmp 0x1672
jmp 0x1672
jmp 0x1672
jmp 0x1672
jmp 0x1672
jmp 0x1672
jmp 0x1672
jmp 0x1672
movq %rax, %rbx
jmp 0x1681
jmp 0x1653
jmp 0x1672
jmp 0x1653
movq %rax, %rbx
jmp 0x168d
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x1758
leaq -0xd0(%rbp), %rdi
callq 0x17b4
jmp 0x1675
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x1758
leaq -0xa0(%rbp), %rdi
callq 0x1758
leaq -0x40(%rbp), %rdi
callq 0x1830
movq %rbx, %rdi
callq 0x1180