Skip to content

Commit 91096ec

Browse files
Merge branch 'main' into log-entry
2 parents 75ba6b0 + 7f2a8a4 commit 91096ec

File tree

108 files changed

+8558
-54
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+8558
-54
lines changed

bin/concept-of-the-week.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
content/typescript/concepts/interfaces/interfaces.md
1+
content/sklearn/concepts/probability-calibration/probability-calibration.md

content/c-sharp/concepts/conditionals/conditionals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Is this condition true ? Run this if yes : Run this if no;
127127
In the example below, the condition that is checked is if `input1` is equal to 10. If that condition is true, it returns the first string. Otherwise, it returns the second string:
128128

129129
```cs
130-
string getInput1(int input1) => input1 === 10 ? "I returned true" : "I returned false";
130+
string getInput1(int input1) => input1 == 10 ? "I returned true" : "I returned false";
131131

132132
Console.WriteLine(getInput1(10)); // Output: "I returned true"
133133
Console.WriteLine(getInput1(5)); // Output: "I returned false"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
Title: 'Cloud Storage'
3+
Description: 'A service that allows users to store and access data remotely over the internet.'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Data Science'
7+
Tags:
8+
- 'Cloud Computing'
9+
- 'Storage'
10+
- 'Data'
11+
- 'Infrastructure'
12+
CatalogContent:
13+
- 'foundations-of-cloud-computing'
14+
- 'paths/back-end-engineer-career-path'
15+
---
16+
17+
**Cloud storage** provides on-demand storage services over the internet, eliminating the need for physical storage infrastructure. Users can store, access, and manage data remotely through cloud providers, paying only for the storage they use.
18+
19+
## Object storage
20+
21+
Designed for storing large amounts of unstructured data. Data is stored as objects with metadata and unique identifiers. Object storage is highly scalable and commonly used for:
22+
23+
- Backup and archival data
24+
- Media files (images, videos, audio)
25+
- Web content and static assets
26+
- Big data analytics
27+
28+
## Block storage
29+
30+
Provides raw storage volumes that can be attached to virtual machines. Data is stored in fixed-size blocks and is ideal for:
31+
32+
- Operating system storage
33+
- Database storage
34+
- High-performance applications
35+
- Applications requiring low latency
36+
37+
## File storage
38+
39+
Shared file systems that can be accessed by multiple users and applications. It organizes data in a hierarchical structure and is suitable for:
40+
41+
- Shared document storage
42+
- Application data that requires file system access
43+
- Content management systems
44+
- Collaborative work environments
45+
46+
All major cloud providers offer services across these three storage categories, each optimized for different performance requirements and use cases.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
Title: '.back()'
3+
Description: 'Returns a reference to the last element in the deque.'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Game Development'
7+
Tags:
8+
- 'Containers'
9+
- 'Data Structures'
10+
- 'Deques'
11+
- 'Methods'
12+
CatalogContent:
13+
- 'learn-c-plus-plus'
14+
- 'paths/computer-science'
15+
---
16+
17+
In C++, the **`.back()`** [method](https://www.codecademy.com/resources/docs/cpp/methods) returns a reference to the last element in a [deque](https://www.codecademy.com/resources/docs/cpp/deque). It allows direct access to that element for reading or modifying without removing it.
18+
19+
> **Note:** Calling `.back()` on an empty deque leads to undefined behavior. Check with [`.empty()`](https://www.codecademy.com/resources/docs/cpp/deque/empty) before using `.back()`.
20+
21+
## Syntax
22+
23+
```pseudo
24+
dequeName.back();
25+
```
26+
27+
**Parameters:**
28+
29+
This method does not take any parameters.
30+
31+
**Return value:**
32+
33+
Returns a reference to the last element of the deque. If the deque is `const`, it returns a `const` reference.
34+
35+
## Example: Accessing and Updating the Last Element
36+
37+
This example retrieves the last number in a deque, updates it, and displays the change:
38+
39+
```cpp
40+
#include <deque>
41+
#include <iostream>
42+
43+
int main() {
44+
std::deque<int> scores = {45, 67, 89};
45+
46+
std::cout << "Last score: " << scores.back() << std::endl;
47+
48+
// Update the last element
49+
scores.back() = 100;
50+
51+
std::cout << "Updated last score: " << scores.back() << std::endl;
52+
return 0;
53+
}
54+
```
55+
56+
This program produces the following output:
57+
58+
```shell
59+
Last score: 89
60+
Updated last score: 100
61+
```
62+
63+
## Codebyte Example: Using `.back()` in a Conditional Check
64+
65+
This example shows how `.back()` can be used to verify or modify the final value in a deque:
66+
67+
```codebyte/cpp
68+
#include <deque>
69+
#include <iostream>
70+
71+
int main() {
72+
std::deque<std::string> tasks = {"plan", "write", "review"};
73+
74+
if (tasks.back() == "review") {
75+
tasks.back() = "submit"; // Update the last task
76+
}
77+
78+
std::cout << "Final task: " << tasks.back() << std::endl;
79+
return 0;
80+
}
81+
```
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
Title: '.front()'
3+
Description: 'Returns a reference to the first element of the deque'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Game Development'
7+
Tags:
8+
- 'Classes'
9+
- 'Containers'
10+
- 'Deques'
11+
- 'OOP'
12+
CatalogContent:
13+
- 'learn-c-plus-plus'
14+
- 'paths/computer-science'
15+
---
16+
17+
In C++, the **`.front()`** [method](https://www.codecademy.com/resources/docs/cpp/methods) returns a reference to the first element in the [deque](https://www.codecademy.com/resources/docs/python/deque).
18+
19+
## Syntax
20+
21+
```pseudo
22+
deque_name.front()
23+
```
24+
25+
**Parameters:**
26+
27+
`.front()` does not take any parameters
28+
29+
**Return value:**
30+
31+
- Returns a reference to the first element of the deque.
32+
- For a non-const deque, returns `T&` (modifiable).
33+
- For a const deque, returns const `T&` (read-only).
34+
35+
## Example
36+
37+
The example below demonstrates use of `.front()` to access the first element in a deque:
38+
39+
```cpp
40+
#include <iostream>
41+
#include <deque>
42+
43+
int main() {
44+
// Create a deque of integers
45+
std::deque<int> numbers;
46+
47+
// Add some elements to the deque
48+
numbers.push_back(100);
49+
numbers.push_back(200);
50+
numbers.push_back(300);
51+
52+
// Access the first element using .front()
53+
std::cout << "First element: " << numbers.front() << std::endl;
54+
55+
// Modify the first element
56+
numbers.front() = 50;
57+
58+
// Display updated deque contents
59+
std::cout << "Updated deque: ";
60+
for (int num : numbers) {
61+
std::cout << num << " ";
62+
}
63+
std::cout << std::endl;
64+
65+
return 0;
66+
}
67+
```
68+
69+
The output of this program will be:
70+
71+
```shell
72+
First element: 100
73+
Updated deque: 50 200 300
74+
```
75+
76+
This shows that `.front()` allows both access and modification of the deque’s first element.
77+
78+
## Codebyte Example
79+
80+
Run the following codebyte example to understand the use of `.front()` method:
81+
82+
```codebyte/cpp
83+
#include <iostream>
84+
#include <deque>
85+
#include <string>
86+
87+
int main() {
88+
// Create a deque of strings
89+
std::deque<std::string> myDeque;
90+
91+
// Add elements to the deque
92+
myDeque.push_back("Hello");
93+
myDeque.push_back("World");
94+
myDeque.push_back("!");
95+
96+
// Print the front element
97+
std::cout << "Front element before change: " << myDeque.front() << std::endl;
98+
99+
// Modify the front element
100+
myDeque.front() = "Hi";
101+
102+
// Print the modified front element
103+
std::cout << "Front element after change: " << myDeque.front() << std::endl;
104+
105+
// Print all elements of the deque
106+
std::cout << "Complete deque: ";
107+
for (const auto& str : myDeque) {
108+
std::cout << str << " ";
109+
}
110+
std::cout << std::endl;
111+
112+
return 0;
113+
}
114+
```
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
Title: '.max_size()'
3+
Description: 'Returns the maximum number of elements a deque can hold.'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Game Development'
7+
Tags:
8+
- 'Classes'
9+
- 'Containers'
10+
- 'Deques'
11+
- 'OOP'
12+
CatalogContent:
13+
- 'learn-c-plus-plus'
14+
- 'paths/computer-science'
15+
---
16+
17+
In C++, the **`.max_size()`** [method](https://www.codecademy.com/resources/docs/cpp/methods) returns the maximum number of elements a deque can hold. This value reflects the maximum possible size based on system or library constraints. However, it does not guarantee that the container can actually grow to that size—memory allocation may still fail before reaching the reported limit.
18+
19+
## Syntax
20+
21+
```pseudo
22+
dequeName.max_size();
23+
```
24+
25+
**Parameters:**
26+
27+
The method does not take any parameters.
28+
29+
**Return value:**
30+
31+
Returns the maximum number of elements the deque can potentially hold as a value of type `size_type`.
32+
33+
## Example
34+
35+
In this example, the maximum possible number of elements a deque can hold on the system is retrieved:
36+
37+
```cpp
38+
#include <iostream>
39+
#include <deque>
40+
41+
int main() {
42+
std::deque<int> mydeque;
43+
44+
// Display the maximum possible number of elements
45+
std::cout << "Maximum possible elements: " << mydeque.max_size() << '\n';
46+
}
47+
```
48+
49+
Example output on a 64-bit system:
50+
51+
```shell
52+
Maximum possible elements: 4611686018427387903
53+
```
54+
55+
## Codebyte Example
56+
57+
In this example, a requested size is compared with the maximum possible size of a deque, and the container is resized only if the size is allowed:
58+
59+
```codebyte/cpp
60+
#include <iostream>
61+
#include <deque>
62+
63+
int main() {
64+
65+
std::deque<int> mydeque;
66+
unsigned int requested_size = 5; // example requested size
67+
68+
if (requested_size < mydeque.max_size()) {
69+
mydeque.resize(requested_size);
70+
std::cout << "Deque resized to " << requested_size << " elements.\n";
71+
} else {
72+
std::cout << "Requested size exceeds maximum allowed.\n";
73+
}
74+
75+
std::cout << "Current deque size: " << mydeque.size() << std::endl;
76+
77+
return 0;
78+
}
79+
```

0 commit comments

Comments
 (0)