Chaper 11. Associate Container

本文详细介绍了C++中关联容器如map、set、multimap、multiset的基本特性和操作,包括迭代器使用、插入、删除等关键概念。同时解释了这些容器如何处理唯一和多重键值对,以及如何通过迭代器遍历元素。最后讨论了在使用这些容器时可能遇到的问题,如插入操作和引用参数错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.

The associative containers do not support the sequential-container position-specific operations, suchas push_front or back

The associative containers do not support the constructors or insert operations that take anelement value and a count. 

The associative container iterators are bidirectional.

2.

When we initialize a map, we have to supply both the key and the value. We wrap each key–value pair inside curly braces:

{key, value

3.

When we dereference an iterator, we get a reference to a value of the container’svalue_type. In the case of map, the value_type is a pair in which first holdsthe const key and second holds the value 

4.

Although the set types define both the iterator and const_iterator types, both types of iterators give us read-only access to the elements in the set. Just as we cannot change the key part of a map element, the keys in a set are also const. Wecan use a set iterator to read, but not write, an element’s value.

5.

When we use an iteratorto traverse a map, multimap, set, or multiset, the iterators yieldelements in ascending key order. 


6.

For the containers that have unique keys, the versions of insert and emplace that add a single element return a pair that lets us know whether the insertion happened. The first member of the pair is an iterator to the element with the given key; the second is a bool indicating whether that element was inserted, or was already there. If the key is already in the container, then insert does nothing, and the bool portion of the return value is false. If the key isn’t present, then the element is inserted and the bool is true

For the containers that allow multiple keys, the insert operation that takes a singleelement returns an iterator to the new element. 


7.

Today I was trying to use:
auto ret = iset.insert(std::advance(itr, 3), 1);
Compiler complained an error. The reason is that the function returns void. itr is a reference parameter. That's how its value gets changed.

8.

we can erase one element or a rangeof elements by passing erase an iterator or an iterator pair.


9.

Because the subscript operator might insert an element, we may use subscript only ona map that is not const

10.P547

c.find(k), c.count(k), c.lower_bound(k), c.upper_bound(k), c.equal_range(k)

11.

We are guaranteed that iterating across a multimap or multiset returnsall the elements with a given key in sequence. 


12.

If the key is in the container, the iterator returned from lower_bound will refer to the first instance ofthat key and the iterator returned by upper_bound will refer just after the last instance of the key. 

If the element is not in the multimap, then lower_bound andupper_bound will return equal iterators; both will refer to the point at which the key can be inserted without disrupting the order. 

This function equal_range takes a key and returns a pair of iterators. If the key is present, then the first iterator refers to the first instance of the key and the second iterator refers one past the last instance of the key. If no matching element is found, then both the first and second iterators refer to the position where this key can be inserted. 

13.

Use an unordered container if the key type is inherently unordered or ifperformance testing reveals problems that hashing might solve.

page556image9264



### 802.11 关联过程 在无线网络中,设备连接到接入点(AP)的过程称为关联。以下是详细的 802.11 关联流程: #### 探测阶段 客户端设备通过发送探测请求帧来查找可用的 AP。这些请求可以是有针对性的(指定 SSID),也可以是非特定性的(广播)。当 AP 收到探测请求时,会回复一个探测响应帧,其中包含了关于该 AP 的信息,如支持的数据速率、认证方式和支持的安全协议等。 #### 认证阶段 一旦选择了合适的 AP 后,客户端将尝试进行身份验证。这通常涉及两种模式之一:开放系统认证或共享密钥认证。对于现代安全标准而言,此步骤还包括四次握手交换以建立加密密钥[^2]。 ```python def authenticate(client, ap): if client.request == "open": return True elif client.request == "shared_key": # Perform shared key authentication logic here pass ``` #### 关联阶段 成功完成认证之后,客户端向选定的 AP 发送关联请求帧。这个帧内含有有关其能力的信息以及所期望的服务集标识符 (SSID) 和其他参数。如果一切正常,则 AP 将返回确认消息给客户端并允许它加入网络;否则可能会拒绝此次请求。 #### 数据传输准备 最后,在正式开始数据通信之前还需要一些准备工作,比如设置 QoS 参数等[^3]。 ### 解决常见问题的方法 - **信号强度不足**:确保终端处于合理范围内,并且没有太多障碍物阻挡。 - **信道冲突**:检查周围是否存在干扰源,考虑更改工作频段或者调整发射功率。 - **不兼容配置**:更新固件版本至最新状态,保证两端都遵循相同的规格说明。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值