Translate all code to English (#1836)

* Review the EN heading format.

* Fix pythontutor headings.

* Fix pythontutor headings.

* bug fixes

* Fix headings in **/summary.md

* Revisit the CN-to-EN translation for Python code using Claude-4.5

* Revisit the CN-to-EN translation for Java code using Claude-4.5

* Revisit the CN-to-EN translation for Cpp code using Claude-4.5.

* Fix the dictionary.

* Fix cpp code translation for the multipart strings.

* Translate Go code to English.

* Update workflows to test EN code.

* Add EN translation for C.

* Add EN translation for CSharp.

* Add EN translation for Swift.

* Trigger the CI check.

* Revert.

* Update en/hash_map.md

* Add the EN version of Dart code.

* Add the EN version of Kotlin code.

* Add missing code files.

* Add the EN version of JavaScript code.

* Add the EN version of TypeScript code.

* Fix the workflows.

* Add the EN version of Ruby code.

* Add the EN version of Rust code.

* Update the CI check for the English version  code.

* Update Python CI check.

* Fix cmakelists for en/C code.

* Fix Ruby comments
This commit is contained in:
Yudong Jin
2025-12-31 07:44:52 +08:00
committed by GitHub
parent 45e1295241
commit 2778a6f9c7
1284 changed files with 71557 additions and 3275 deletions
@@ -6,17 +6,17 @@
#include "../utils/common.hpp"
/* Queue class based on circular array */
/* Queue based on circular array implementation */
class ArrayQueue {
private:
int *nums; // Array for storing queue elements
int front; // Front pointer, pointing to the front element
int front; // Front pointer, points to the front of the queue element
int queSize; // Queue length
int queCapacity; // Queue capacity
public:
ArrayQueue(int capacity) {
// Initialize an array
// Initialize array
nums = new int[capacity];
queCapacity = capacity;
front = queSize = 0;
@@ -36,7 +36,7 @@ class ArrayQueue {
return queSize;
}
/* Determine if the queue is empty */
/* Check if the queue is empty */
bool isEmpty() {
return size() == 0;
}
@@ -47,10 +47,10 @@ class ArrayQueue {
cout << "Queue is full" << endl;
return;
}
// Calculate rear pointer, pointing to rear index + 1
// Use modulo operation to wrap the rear pointer from the end of the array back to the start
// Use modulo operation to wrap rear around to the head after passing the tail of the array
// Add num to the rear of the queue
int rear = (front + queSize) % queCapacity;
// Add num to the rear
// Front pointer moves one position backward
nums[rear] = num;
queSize++;
}
@@ -58,13 +58,13 @@ class ArrayQueue {
/* Dequeue */
int pop() {
int num = peek();
// Move front pointer one position backward, returning to the head of the array if it exceeds the tail
// Move front pointer backward by one position, if it passes the tail, return to array head
front = (front + 1) % queCapacity;
queSize--;
return num;
}
/* Access front element */
/* Return list for printing */
int peek() {
if (isEmpty())
throw out_of_range("Queue is empty");
@@ -73,7 +73,7 @@ class ArrayQueue {
/* Convert array to Vector and return */
vector<int> toVector() {
// Only convert elements within valid length range
// Elements enqueue
vector<int> arr(queSize);
for (int i = 0, j = front; i < queSize; i++, j++) {
arr[i] = nums[j % queCapacity];
@@ -84,11 +84,11 @@ class ArrayQueue {
/* Driver Code */
int main() {
/* Initialize queue */
/* Access front of the queue element */
int capacity = 10;
ArrayQueue *queue = new ArrayQueue(capacity);
/* Element enqueue */
/* Elements enqueue */
queue->push(1);
queue->push(3);
queue->push(2);
@@ -97,28 +97,28 @@ int main() {
cout << "Queue queue = ";
printVector(queue->toVector());
/* Access front element */
/* Return list for printing */
int peek = queue->peek();
cout << "Front element peek = " << peek << endl;
/* Element dequeue */
peek = queue->pop();
cout << "Element dequeued = " << peek << ", after dequeuing";
cout << "Dequeue element pop = " << peek << ", after dequeue, queue = ";
printVector(queue->toVector());
/* Get the length of the queue */
int size = queue->size();
cout << "Length of the queue size = " << size << endl;
cout << "Queue length size = " << size << endl;
/* Determine if the queue is empty */
/* Check if the queue is empty */
bool empty = queue->isEmpty();
cout << "Is the queue empty = " << empty << endl;
cout << "Queue is empty = " << empty << endl;
/* Test circular array */
for (int i = 0; i < 10; i++) {
queue->push(i);
queue->pop();
cout << "After the " << i << "th round of enqueueing + dequeuing, queue = ";
cout << "After round " << i << " enqueue + dequeue, queue = ";
printVector(queue->toVector());
}