This commit is contained in:
krahets
2023-10-17 20:29:28 +08:00
parent 44ebc7748b
commit de9bf5a57a
5 changed files with 44 additions and 8 deletions
+1 -1
View File
@@ -1152,7 +1152,7 @@ comments: true
/* 链表节点 */
struct node {
Pair *pair;
struct Node *next;
struct node *next;
};
typedef struct node Node;
+8 -4
View File
@@ -965,14 +965,18 @@ index = hash(key) % capacity
```swift title="array_hash_map.swift"
/* 键值对 */
class Pair {
var key: Int
var val: String
class Pair: Equatable {
public var key: Int
public var val: String
init(key: Int, val: String) {
public init(key: Int, val: String) {
self.key = key
self.val = val
}
public static func == (lhs: Pair, rhs: Pair) -> Bool {
lhs.key == rhs.key && lhs.val == rhs.val
}
}
/* 基于数组简易实现的哈希表 */