Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Commit b4aefa2

Browse files
committed
Update reserve.md
1 parent bf24a81 commit b4aefa2

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

content/cpp/concepts/unordered-set/terms/reserve/reserve.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Title: 'reserve()'
3-
Description: 'Requests capacity change for `std::unordered_set` so it can accommodate at least n elements without exceeding the maximum load factor.'
3+
Description: 'Requests capacity change for an unordered set so it can accommodate at least n elements without exceeding the maximum load factor.'
44
Subjects:
55
- 'Code Foundations'
66
- 'Computer Science'
@@ -13,7 +13,7 @@ CatalogContent:
1313
- 'paths/computer-science'
1414
---
1515

16-
The **`reserve()`** method requests a capacity change for an [`std::unordered_set`](https://www.codecademy.com/resources/docs/cpp/unordered-set). It sets the number of buckets to the amount needed to accommodate at least `n` elements without exceeding the container’s `max_load_factor()`. Calling `reserve(n)` may trigger a rehash; if it does, all iterators are invalidated, but references and pointers to elements remain valid. This operation does not sort or otherwise order elements.
16+
The **`reserve()`** method requests a capacity change for an `std::unordered_set`. It sets the number of buckets to the amount needed to accommodate at least `n` elements without exceeding the container’s `max_load_factor()`. Calling `reserve(n)` may trigger a rehash; if it does, all iterators are invalidated, but references and pointers to elements remain valid. This operation does not sort elements or impose any ordering.
1717

1818
## Syntax
1919

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
Title: '.querySelectorAll()'
3+
Description: 'Returns a static (non-live) NodeList of all elements in the document that match the given CSS selectors.'
4+
Subjects:
5+
- 'Code Foundations'
6+
- 'Web Development'
7+
Tags:
8+
- 'Methods'
9+
- 'Node'
10+
- 'Selectors'
11+
CatalogContent:
12+
- 'introduction-to-javascript'
13+
- 'paths/front-end-engineer-career-path'
14+
---
15+
16+
In JavaScript, the **`.querySelectorAll()`** method under the `document` object returns a static (not live) `NodeList` of all elements that match the given group of [selectors](https://www.codecademy.com/resources/docs/css/selectors).
17+
18+
## Syntax
19+
20+
```pseudo
21+
document.querySelectorAll(selectors);
22+
```
23+
24+
- `selectors`: Represents a string containing one or more CSS selectors used to match elements in the document. It follows the same rules as CSS selectors and can include:
25+
- Type selectors (`div`, `p`, `span`)
26+
- Class selectors (`.class-name`)
27+
- ID selectors (`#id-name`)
28+
- Attribute selectors (`[type="text"]`, `[disabled]`)
29+
- Combinations (`div p`, `.container > p`, `ul > li:first-child`)
30+
31+
## Examples
32+
33+
### Example 1
34+
35+
In this example, a `NodeList` of all `<p>` elements in the document is obtained:
36+
37+
```js
38+
const matches = document.querySelectorAll('p');
39+
```
40+
41+
### Example 2
42+
43+
The following example returns a list of all `<div>` elements in the document with a class of either `note` or `alert`:
44+
45+
```js
46+
const matches = document.querySelectorAll('div.note, div.alert');
47+
```
48+
49+
### Example 3
50+
51+
In this example, a list of `<p>` elements is obtained, whose immediate parent is a `<div>` with the class `highlighted`, and which are inside a container with the ID `test`:
52+
53+
```js
54+
const container = document.querySelector('#test');
55+
const matches = container.querySelectorAll('div.highlighted > p');
56+
```

0 commit comments

Comments
 (0)