You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/cpp/concepts/unordered-set/terms/bucket-size/bucket-size.md
+9-11Lines changed: 9 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
---
2
-
Title: 'bucket_size()'# Required; the file name should be the same as the title, but lowercase, with dashes instead of spaces, and all punctuation removed
3
-
Description: 'Returns the number of elements stored in a specific bucket of an unordered_map.'# Required; ideally under 150 characters and starts with a present-tense verb (used in search engine results and content previews)
4
-
Subjects:# Please only use Subjects in the subjects.md file (https://github.com/Codecademy/docs/blob/main/documentation/subjects.md). If that list feels insufficient, feel free to create a new Subject and add it to subjects.md in your PR!
2
+
Title: 'bucket_size()'
3
+
Description: 'Returns the number of elements stored in a specific bucket of an unordered_map.'
4
+
Subjects:
5
5
- 'Code Foundations'
6
6
- 'Computer Science'
7
-
Tags:# Please only use Tags in the tags.md file (https://github.com/Codecademy/docs/blob/main/documentation/tags.md). If that list feels insufficient, feel free to create a new Tag and add it to tags.md in your PR!
7
+
Tags:
8
8
- 'Optimization'
9
-
CatalogContent:# Please use course/path landing page slugs, rather than linking to individual content items. If listing multiple items, please put the most relevant one first
9
+
CatalogContent:
10
10
- 'learn-c-plus-plus'
11
11
- 'paths/computer-science'
12
12
---
13
13
14
-
The **.bucket_size()** method returns the number of elements stored in a specific bucket of an [`unordered_map](https://www.codecademy.com/resources/docs/cpp/unordered-map). In C++, an unordered_map uses a hash table internally where elements are distributed across multiple buckets based on their key’s hash value. This method helps analyze the distribution of elements and can be useful for performance optimization and understanding collision handling in the hash table.
14
+
The **.bucket_size()** method returns the number of elements stored in a specific bucket of an [`unordered_map`](https://www.codecademy.com/resources/docs/cpp/unordered-map). In C++, an unordered_map uses a hash table internally where elements are distributed across multiple buckets based on their key’s hash value. This method helps analyze the distribution of elements and can be useful for performance optimization and understanding collision handling in the hash table.
15
15
16
16
## Syntax
17
17
@@ -20,7 +20,7 @@ unordered_map.bucket_size(n)
20
20
```
21
21
**Parameters:**
22
22
23
-
*n*: The bucket number to query. This value must be less than the total number of buckets returned by .bucket_count(). It is of type size_type, which is an unsigned integral type.
23
+
n: The bucket number to query. This value must be less than the total number of buckets returned by .bucket_count(). It is of type size_type, which is an unsigned integral type.
24
24
Return value:
25
25
26
26
The .bucket_size() method returns the number of elements in bucket n as an unsigned integer of type size_type.
@@ -29,8 +29,7 @@ The .bucket_size() method returns the number of elements in bucket n as an unsig
29
29
30
30
This example demonstrates how to use .bucket_size() to check the number of elements in each bucket of an unordered_map:
0 commit comments