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

Commit 490532d

Browse files
authored
Update max-size.md
1 parent c07c64f commit 490532d

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

  • content/cpp/concepts/unordered-set/terms/max-size

content/cpp/concepts/unordered-set/terms/max-size/max-size.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Title: 'max_size()'
3-
Description: 'Returns the maximum number of elements that the container can theoretically hold.'
3+
Description: 'Returns the maximum number of elements that an unordered_set can theoretically hold.'
44
Subjects:
55
- 'Code Foundations'
66
- 'Computer Science'
@@ -13,7 +13,7 @@ CatalogContent:
1313
- 'paths/computer-science'
1414
---
1515

16-
The **`.max_size()`** member function returns the maximum number of elements a container can theoretically hold. This limit depends on the system and the implementation of the standard library, not on actual available memory.
16+
The **`.max_size()`** member [function](https://www.codecademy.com/resources/docs/cpp/functions) returns the maximum number of elements an `unordered_set` can theoretically hold. This limit depends on the system and the implementation of the standard library, not on actual available memory.
1717

1818
## Syntax
1919

@@ -31,7 +31,7 @@ The method returns a value of type `size_type`, representing the theoretical max
3131

3232
## Example 1: Basic Usage
3333

34-
In this example the program prints the maximum number of elements an `unordered_set` can theoretically hold:
34+
In this example, the program prints the maximum number of elements an `unordered_set` can theoretically hold:
3535

3636
```cpp
3737
#include <iostream>
@@ -46,17 +46,17 @@ int main() {
4646
}
4747
```
4848

49-
This example outputs the maximum possible size of the `unordered_set`:
49+
The output will be:
5050

5151
```shell
5252
Maximum size: 1152921504606846975
5353
```
5454

5555
> **Note:** The actual value may vary depending on the system and implementation.
5656
57-
## Example 2: Different Data Types
57+
## Example 2: Using Different Data Types
5858

59-
In this example the `max_size()` value is shown for `unordered_set` containers holding different data types:
59+
In this example, the `max_size()` value is shown for `unordered_set` containers holding different [data types](https://www.codecademy.com/resources/docs/cpp/data-types):
6060

6161
```cpp
6262
#include <iostream>
@@ -67,25 +67,25 @@ int main() {
6767
std::unordered_set<double> double_set;
6868
std::unordered_set<char> char_set;
6969

70-
std::cout << "int max_size: " << int_set.max_size() << std::endl;
71-
std::cout << "double max_size: " << double_set.max_size() << std::endl;
72-
std::cout << "char max_size: " << char_set.max_size() << std::endl;
70+
std::cout << "int max size: " << int_set.max_size() << std::endl;
71+
std::cout << "double max size: " << double_set.max_size() << std::endl;
72+
std::cout << "char max size: " << char_set.max_size() << std::endl;
7373

7474
return 0;
7575
}
7676
```
7777

78-
This demonstrates that `max_size()` can vary based on the element type:
78+
The output will be:
7979

8080
```shell
81-
int max_size: 1152921504606846975
82-
double max_size: 1152921504606846975
83-
char max_size: 1152921504606846975
81+
int max size: 1152921504606846975
82+
double max size: 1152921504606846975
83+
char max size: 1152921504606846975
8484
```
8585

8686
## Codebyte Example
8787

88-
In this example the program compares the current size of an `unordered_set` with its theoretical maximum:
88+
In this example, the program compares the current size of an `unordered_set` with its theoretical maximum:
8989

9090
```codebyte/cpp
9191
#include <iostream>

0 commit comments

Comments
 (0)