Retranslate the complete English edition from Simplified Chinese (#2010)

* Retranslate the complete English edition from Simplified Chinese

* Polish three English explanations after reader-focused review
This commit is contained in:
Yudong Jin
2026-10-31 03:35:51 +08:00
committed by GitHub
parent ef46e2ed95
commit 14c314c08c
1502 changed files with 29459 additions and 23517 deletions

View File

@@ -17,14 +17,14 @@ struct Pair {
}
};
/* Hash table based on array implementation */
/* Hash table implemented with an array */
class ArrayHashMap {
private:
vector<Pair *> buckets;
public:
ArrayHashMap() {
// Initialize array with 100 buckets
// Initialize an array containing 100 buckets
buckets = vector<Pair *>(100);
}
@@ -42,7 +42,7 @@ class ArrayHashMap {
return index;
}
/* Query operation */
/* Lookup operation */
string get(int key) {
int index = hashFunc(key);
Pair *pair = buckets[index];
@@ -51,7 +51,7 @@ class ArrayHashMap {
return pair->val;
}
/* Add operation */
/* Insert operation */
void put(int key, string val) {
Pair *pair = new Pair(key, val);
int index = hashFunc(key);
@@ -61,7 +61,7 @@ class ArrayHashMap {
/* Remove operation */
void remove(int key) {
int index = hashFunc(key);
// Free memory and set to nullptr
// Free the memory and set the pointer to nullptr
delete buckets[index];
buckets[index] = nullptr;
}
@@ -99,7 +99,7 @@ class ArrayHashMap {
return valueSet;
}
/* Print hash table */
/* Print the hash table */
void print() {
for (Pair *kv : pairSet()) {
cout << kv->key << " -> " << kv->val << endl;
@@ -107,4 +107,4 @@ class ArrayHashMap {
}
};
// See array_hash_map_test.cpp for test cases
// See array_hash_map_test.cpp for the test example