C++学习——哈希表(一)

news2025/3/11 6:52:14

文章目录

  • 前言
  • 一、哈希表的模板代码
  • 二、哈希计数器
  • 三、哈希表中的无序映射
  • 四、哈希表的总结


前言

本文为《C++学习》的第11篇文章,今天学习最后一个数据结构哈希表(散列表)。


一、哈希表的模板代码

#include<iostream>
using namespace std;

// 哈希表节点模板类(链地址法实现)
template<typename KeyType, typename ValueType>
class HashNode {
public:
    KeyType key;            // 键(支持泛型)
    ValueType value;        // 值(支持泛型)
    HashNode *next;         // 指向下一个节点的指针
    
    // 构造函数(初始化键值对)
    HashNode(const KeyType &key, const ValueType &value) {
        this->key = key;
        this->value = value;
        this->next = nullptr;
    }
};

// 哈希表模板类
template<typename KeyType, typename ValueType>
class HashTable {
private:
    int size;                            // 哈希表桶数量
    HashNode<KeyType, ValueType> **table;// 桶数组(指针数组)

    // 哈希函数(简单取模法,仅适合整数类型键)
    int hash(const KeyType &key) const {
        int hashkey = key % size;        // 核心哈希计算[3](@ref)
        if(hashkey < 0) hashkey += size; // 处理负数键
        return hashkey;
    }
        
public:
    HashTable(int size = 256);          // 构造函数(默认桶数256)
    ~HashTable();                       // 析构函数(释放内存)
    void insert(const KeyType &key, const ValueType &value); // 插入键值对
    void remove(const KeyType &key);    // 删除键
    bool find(const KeyType &key, ValueType &value) const; // 查找键
};

/* 构造函数:初始化桶数组 */
template<typename KeyType, typename ValueType>
HashTable<KeyType, ValueType>::HashTable(int size) {
    this->size = size;
    this->table = new HashNode<KeyType, ValueType> *[size]; // 动态分配桶数组
    for(int i = 0; i < size; ++i) {
        this->table[i] = nullptr; // 初始化所有桶为空
    }
}

/* 析构函数:释放所有节点内存 */
template<typename KeyType, typename ValueType>
HashTable<KeyType, ValueType>::~HashTable() {
    for(int i = 0; i < size; ++i) {
        HashNode<KeyType, ValueType> *current = table[i];
        while(current) { // 遍历链表释放节点
            HashNode<KeyType, ValueType> *next = current->next;
            delete current; // 释放当前节点
            current = next;
        }
    }
    delete[] table; // 修正:需用delete[]释放数组[1](@ref)
}

/* 插入操作(头插法,时间复杂度O(1)) */
template<typename KeyType, typename ValueType>
void HashTable<KeyType, ValueType>::insert(const KeyType &key, const ValueType &value) {
    int index = hash(key); // 计算桶索引
    HashNode<KeyType, ValueType> *newNode = new HashNode<KeyType, ValueType>(key, value);
    // 头插法插入链表
    newNode->next = table[index]; // 新节点指向原链表头
    table[index] = newNode;        // 更新链表头为新节点[3](@ref)
}

/* 删除操作(需处理头节点和中间节点) */
template<typename KeyType, typename ValueType>
void HashTable<KeyType, ValueType>::remove(const KeyType &key) {
    int index = hash(key);
    if (!table[index]) return; // 空桶直接返回

    // 情况1:删除头节点
    if (table[index]->key == key) {
        HashNode<KeyType, ValueType> *temp = table[index];
        table[index] = table[index]->next; // 头节点指向下一个节点
        delete temp;
        return;
    }

    // 情况2:删除中间节点
    HashNode<KeyType, ValueType> *current = table[index];
    while (current->next && current->next->key != key) {
        current = current->next;
    }
    if (current->next) { // 找到目标节点
        HashNode<KeyType, ValueType> *temp = current->next;
        current->next = temp->next; // 跳过被删除节点
        delete temp;
    }
}

/* 查找操作(遍历链表) */
template<typename KeyType, typename ValueType>
bool HashTable<KeyType, ValueType>::find(const KeyType &key, ValueType &value) const {
    int index = hash(key);
    HashNode<KeyType, ValueType> *current = table[index];
    while (current) {
        if (current->key == key) {
            value = current->value; // 返回找到的值
            return true;            
        }
        current = current->next;
    }
    return false; // 未找到返回false
}

int main() {
    // 测试1:基础功能测试(整数键)
    HashTable<int, string> ht(10); // 桶数设为10便于观察冲突

    // 插入测试
    ht.insert(1, "Apple");
    ht.insert(11, "Banana"); // 与1同桶(哈希冲突)
    ht.insert(21, "Orange"); // 继续冲突
    ht.insert(5, "Grape");

    // 查找测试
    string value;
    cout << "--- 查找测试 ---" << endl;
    cout << "查找1: " << (ht.find(1, value) ? value : "Not Found") << endl; // Apple
    cout << "查找11: " << (ht.find(11, value) ? value : "Not Found") << endl; // Banana
    cout << "查找99: " << (ht.find(99, value) ? value : "Not Found") << endl; // Not Found

    // 删除测试
    cout << "\n--- 删除测试 ---" << endl;
    ht.remove(11);
    cout << "删除后查找11: " << (ht.find(11, value) ? value : "Not Found") << endl; // Not Found
    ht.remove(1);
    cout << "删除头节点后查找1: " << (ht.find(1, value) ? value : "Not Found") << endl; // Not Found
    cout << "删除后查找21: " << (ht.find(21, value) ? value : "Not Found") << endl; // Orange(验证链表连接正确性)

    // 测试2:模板类型测试(字符串键需自定义哈希函数,此处需改进)
    // HashTable<string, int> strHT; // 当前哈希函数仅支持整数,需扩展

    // 测试3:性能测试(插入1000个元素)
    HashTable<int, int> perfHT;
    for (int i = 0; i < 1000; ++i) {
        perfHT.insert(i, i*10);
    }
    int foundCount = 0;
    for (int i = 0; i < 1000; ++i) {
        int val;
        if (perfHT.find(i, val)) foundCount++;
    }
    cout << "\n--- 性能测试 ---\n成功查找次数: " << foundCount << "/1000" << endl;

    return 0; 
}

二、哈希计数器

#include<iostream>
#include<string>

using namespace std;

// 哈希表节点模板类(链地址法实现)
template<typename KeyType, typename ValueType>
class HashNode {
public:
    KeyType key;            // 键(支持泛型)
    ValueType value;        // 值(支持泛型)
    HashNode *next;         // 指向下一个节点的指针
    
    // 构造函数(初始化键值对)
    HashNode(const KeyType &key, const ValueType &value) {
        this->key = key;
        this->value = value;
        this->next = nullptr;
    }
};

// 哈希表模板类
template<typename KeyType, typename ValueType>
class HashTable {
private:
    int size;                            // 哈希表桶数量
    HashNode<KeyType, ValueType> **table;// 桶数组(指针数组)

    // 哈希函数(简单取模法,仅适合整数类型键)
    int hash(const KeyType &key) const {
        int hashkey = key % size;        // 核心哈希计算[3](@ref)
        if(hashkey < 0) hashkey += size; // 处理负数键
        return hashkey;
    }
        
public:
    HashTable(int size = 256);          // 构造函数(默认桶数256)
    ~HashTable();                       // 析构函数(释放内存)
    void insert(const KeyType &key, const ValueType &value); // 插入键值对
    void remove(const KeyType &key);    // 删除键
    bool find(const KeyType &key, ValueType &value) const; // 查找键
};

/* 构造函数:初始化桶数组 */
template<typename KeyType, typename ValueType>
HashTable<KeyType, ValueType>::HashTable(int size) {
    this->size = size;
    this->table = new HashNode<KeyType, ValueType> *[size]; // 动态分配桶数组
    for(int i = 0; i < size; ++i) {
        this->table[i] = nullptr; // 初始化所有桶为空
    }
}

/* 析构函数:释放所有节点内存 */
template<typename KeyType, typename ValueType>
HashTable<KeyType, ValueType>::~HashTable() {
    for(int i = 0; i < size; ++i) {
        HashNode<KeyType, ValueType> *current = table[i];
        while(current) { // 遍历链表释放节点
            HashNode<KeyType, ValueType> *next = current->next;
            delete current; // 释放当前节点
            current = next;
        }
    }
    delete[] table; // 修正:需用delete[]释放数组[1](@ref)
}

/* 插入操作(头插法,时间复杂度O(1)) */
template<typename KeyType, typename ValueType>
void HashTable<KeyType, ValueType>::insert(const KeyType &key, const ValueType &value) {
    int index = hash(key); // 计算桶索引
    HashNode<KeyType, ValueType> *newNode = new HashNode<KeyType, ValueType>(key, value);
    // 头插法插入链表
    newNode->next = table[index]; // 新节点指向原链表头
    table[index] = newNode;        // 更新链表头为新节点[3](@ref)
}

/* 删除操作(需处理头节点和中间节点) */
template<typename KeyType, typename ValueType>
void HashTable<KeyType, ValueType>::remove(const KeyType &key) {
    int index = hash(key);
    if (!table[index]) return; // 空桶直接返回

    // 情况1:删除头节点
    if (table[index]->key == key) {
        HashNode<KeyType, ValueType> *temp = table[index];
        table[index] = table[index]->next; // 头节点指向下一个节点
        delete temp;
        return;
    }

    // 情况2:删除中间节点
    HashNode<KeyType, ValueType> *current = table[index];
    while (current->next && current->next->key != key) {
        current = current->next;
    }
    if (current->next) { // 找到目标节点
        HashNode<KeyType, ValueType> *temp = current->next;
        current->next = temp->next; // 跳过被删除节点
        delete temp;
    }
}

/* 查找操作(遍历链表) */
template<typename KeyType, typename ValueType>
bool HashTable<KeyType, ValueType>::find(const KeyType &key, ValueType &value) const {
    int index = hash(key);
    HashNode<KeyType, ValueType> *current = table[index];
    while (current) {
        if (current->key == key) {
            value = current->value; // 返回找到的值
            return true;            
        }
        current = current->next;
    }
    return false; // 未找到返回false
}

/* 哈希计数器模板类
 * 功能:统计任意类型键的出现次数
 * 实现原理:
 *   1. 内部维护一个哈希表,映射键到计数数组索引
 *   2. 计数数组存储实际计数值
 *   3. 链地址法处理哈希冲突 */
template<typename KeyType>
class HashCounter {
private:
    int *counter;           // 计数数组,存储每个键的计数值
    int counterIndex;        // 当前可分配的计数数组索引
    int counterSize;         // 计数数组容量(最大唯一键数)
    HashTable<KeyType, int> *hash; // 哈希表,用于键到索引的映射
    
public:
    /* 构造函数
     * @param size 最大支持的不同键数量 */
    HashCounter(int size = 256);
    
    /* 析构函数:释放动态内存 */
    ~HashCounter();
    
    /* 重置所有计数和映射关系 */
    void reset();
    
    /* 增加键的计数(若不存在则创建)
     * @return 更新后的计数值 */
    int add(const KeyType &key);
    
    /* 减少键的计数(最小为0)
     * @return 更新后的计数值 */
    int sub(const KeyType &key);
    
    /* 获取键的当前计数 */
    int get(const KeyType &key);
};

// 构造函数:初始化计数数组和哈希表
template<typename KeyType>
HashCounter<KeyType>::HashCounter(int size) {
    counterSize = size;
    counterIndex = 0;
    counter = new int[counterSize](); // 动态分配并初始化为0
    hash = new HashTable<KeyType, int>(size); // 哈希表容量与计数数组一致
}

// 析构函数:释放内存
template<typename KeyType>
HashCounter<KeyType>::~HashCounter() {
    delete[] counter;  // 释放计数数组
    delete hash;        // 正确释放哈希表(非数组)
}

// 重置所有计数状态
template<typename KeyType>
void HashCounter<KeyType>::reset() {
    delete hash; // 释放旧哈希表
    hash = new HashTable<KeyType, int>(counterSize); // 新建空哈希表
    counterIndex = 0;
    fill_n(counter, counterSize, 0); // 计数数组清零
}

// 增加键的计数(自动处理新键)
template<typename KeyType>
int HashCounter<KeyType>::add(const KeyType &key) {
    int idx;
    if (!hash->find(key, idx)) {   // 新键处理
        if (counterIndex >= counterSize) { // 容量溢出保护
            cerr << "Error: Counter overflow! Max size: " << counterSize << endl;
            return -1;
        }
        idx = counterIndex++;
        hash->insert(key, idx);    // 插入新键与索引
    }
    return ++counter[idx];         // 计数+1并返回
}

// 减少键的计数(最小为0)
template<typename KeyType>
int HashCounter<KeyType>::sub(const KeyType &key) {
    int idx;
    if (hash->find(key, idx)) {     // 仅处理已存在键
        if (counter[idx] > 0) {
            return --counter[idx];  // 计数-1
        }
    }
    return 0;
}

// 获取键的当前计数
template<typename KeyType>
int HashCounter<KeyType>::get(const KeyType &key) {
    int idx;
    return (hash->find(key, idx)) ? counter[idx] : 0;
}

int main() {
    // 初始化哈希表(桶数设为7便于观察冲突)
    HashTable<int, string> ht(7);
    string value; 

    cout << "===== 测试1:基础插入与查找 =====" << endl;
    ht.insert(101, "Alice");
    ht.insert(202, "Bob");
    cout << "Key 101 -> " << (ht.find(101, value) ? value : "Not Found") << endl; // Alice
    cout << "Key 999 -> " << (ht.find(999, value) ? value : "Not Found") << endl; // Not Found

    cout << "\n===== 测试2:键值更新 =====" << endl;
    ht.insert(202, "Bobby");  // 更新已有键
    ht.find(202, value);
    cout << "Key 202 -> " << value << endl; // Bobby

    cout << "\n===== 测试3:哈希冲突处理 =====" << endl;
    ht.insert(7, "Conflict1");  // 7 % 7 = 0
    ht.insert(14, "Conflict2"); // 14 % 7 = 0
    cout << "Bucket 0 查找测试:" << endl;
    cout << "Key 7 -> " << (ht.find(7, value) ? value : "Not Found") << endl;    // Conflict1
    cout << "Key 14 -> " << (ht.find(14, value) ? value : "Not Found") << endl;  // Conflict2

    cout << "\n===== 测试4:删除操作 =====" << endl;
    ht.remove(202);
    cout << "删除后查找202 -> " << (ht.find(202, value) ? value : "Not Found") << endl; // Not Found

    cout << "\n===== 测试5:负数键处理 =====" << endl;
    ht.insert(-5, "Negative");  // (-5 % 7 + 7) = 2
    cout << "Key -5 -> " << (ht.find(-5, value) ? value : "Not Found") << endl;  // Negative

    return 0;
}

三、哈希表中的无序映射

#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
    // 初始化无序映射容器
    unordered_map<string, int> student_scores;

    /****************** 插入操作 ******************/
    // 方法1: 使用 operator[] 插入新键值对(若键存在则覆盖)
    student_scores["Alice"] = 90;   // 插入 Alice:90
    student_scores["Bob"] = 85;     // 插入 Bob:85
    
    // 方法2: 使用 insert 插入(若键存在则不会覆盖)
    student_scores.insert({"Charlie", 88});  // 插入 Charlie:88
    student_scores.insert(make_pair("David", 92)); // 插入 David:92
    
    // 方法3: 使用 emplace 高效插入(C++11特性)
    student_scores.emplace("Eva", 95);  // 插入 Eva:95

    /****************** 查询操作 ******************/
    // 方法1: 使用 operator[] 查询(若键不存在会创建默认值)
    cout << "Alice's score: " << student_scores["Alice"] << endl; // 输出90
    
    // 方法2: 使用 find 安全查询(推荐)
    auto it = student_scores.find("Bob");
    if (it != student_scores.end()) {
        cout << "Bob's score: " << it->second << endl;  // 输出85
    } else {
        cout << "Bob not found" << endl;
    }

    // 方法3: 使用 count 检查键是否存在
    if (student_scores.count("Charlie")) {
        cout << "Charlie exists" << endl;  // 输出存在
    }

    /****************** 修改操作 ******************/
    // 方法1: 通过 operator[] 直接修改
    student_scores["Alice"] = 95;  // Alice成绩修改为95
    
    // 方法2: 通过迭代器修改(需先查找)
    auto update_it = student_scores.find("David");
    if (update_it != student_scores.end()) {
        update_it->second = 100;  // David成绩修改为100
    }

    /****************** 删除操作 ******************/
    // 方法1: 通过键删除
    student_scores.erase("Eva");  // 删除Eva记录
    
    // 方法2: 通过迭代器删除
    auto del_it = student_scores.find("Charlie");
    if (del_it != student_scores.end()) {
        student_scores.erase(del_it);  // 删除Charlie记录
    }

    /****************** 遍历操作 ******************/
    cout << "\nFinal scores:" << endl;
    for (const auto& pair : student_scores) {  // 范围for遍历
        cout << pair.first << ": " << pair.second << endl;
    }

    // 方法2: 使用迭代器遍历
    cout << "\nIterator traversal:" << endl;
    for (auto it = student_scores.begin(); it != student_scores.end(); ++it) {
        cout << it->first << " => " << it->second << endl;
    }

    /****************** 清空容器 ******************/
    student_scores.clear();
    cout << "\nAfter clear, size: " << student_scores.size() << endl;

    return 0;
}

四、哈希表的总结

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


这就是今天的全部内容了,谢谢大家的观看,不要忘了给一个免费的赞哦!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2313094.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

DeepSeek R1在医学领域的应用与技术分析(Discuss V1版)

DeepSeek R1作为一款高性能、低成本的国产开源大模型,正在深刻重塑医学软件工程的开发逻辑与应用场景。其技术特性,如混合专家架构(MoE)和参数高效微调(PEFT),与医疗行业的实际需求紧密结合,推动医疗AI从“技术驱动”向“场景驱动”转型。以下从具体业务领域需求出发,…

Git 如何配置多个远程仓库和免密登录?

自我简介&#xff1a;4年导游&#xff0c;10年程序员&#xff0c;最近6年一直深耕低代码领域&#xff0c;分享低代码和AI领域见解。 通用后台管理系统 代号&#xff1a;虎鲸 缘由 每次开发后台界面都会有很多相同模块&#xff0c;尝试抽离出公共模块作为快速开发的基座。 目标…

【Linux篇】从冯诺依曼到进程管理:计算机体系与操作系统的核心逻辑

&#x1f4cc; 个人主页&#xff1a; 孙同学_ &#x1f527; 文章专栏&#xff1a;Liunx &#x1f4a1; 关注我&#xff0c;分享经验&#xff0c;助你少走弯路&#xff01; 文章目录 1.冯诺依曼体系结构存储分级理解数据流动 2. 操作系统(Operator System)2.1 概念2.2 设计OS的…

【Linux docker】关于docker启动出错的解决方法。

无论遇到什么docker启动不了的问题 就是 查看docker状态sytemctl status docker查看docker日志sudo journalctl -u docker.service查看docker三个配置文件&#xff1a;/etc/docker/daemon.json&#xff08;如果存在&#xff09; /etc/systemd/system/docker.service&#xff…

【医院内部控制专题】7.医院内部控制环境要素剖析(三):人力资源政策

医院成本核算、绩效管理、运营统计、内部控制、管理会计专题索引 一、引言 在当今医疗行业竞争日益激烈的背景下,医院内部控制的重要性愈发凸显。内部控制作为医院管理的关键组成部分,对于保障医院资产安全、提高会计信息质量、提升运营效率以及实现战略目标起着至关重要的…

计算机网络——交换机

一、什么是交换机&#xff1f; 交换机&#xff08;Switch&#xff09;是局域网&#xff08;LAN&#xff09;中的核心设备&#xff0c;负责在 数据链路层&#xff08;OSI第二层&#xff09;高效转发数据帧。它像一位“智能交通警察”&#xff0c;根据设备的 MAC地址 精准引导数…

CentOS7离线部署安装Dify

离线部署安装Dify 在安装 Dify 之前&#xff0c;请确保您的机器满足以下最低系统要求&#xff1a; CPU > 2 核 内存 > 4 GiB 1.安装docker和docker compose 启动 Dify 服务器最简单的方式是通过docker compose。因此现在服务器上安装好docker和docker compose&#xf…

力扣hot100_二叉树(4)_python版本

一、199. 二叉树的右视图 思路&#xff1a; 直接复用层序遍历的代码&#xff0c;然后取每层的最后一个节点代码&#xff1a; class Solution:def rightSideView(self, root: Optional[TreeNode]) -> List[int]:层序遍历取每层的第一个if not root: return []res []queue …

bug-Ant中a-select的placeholder不生效(绑定默认值为undefined)

1.问题 Ant中使用a-select下拉框时&#xff0c;placeholder设置输入框显示默认值提示&#xff0c;vue2ant null与undefined在js中明确的区别&#xff1a; null&#xff1a;一个值被定义&#xff0c;定义为“空值” undefined&#xff1a;根本不存在定义 2.解决 2.1 a-select使…

颠覆语言认知的革命!神经概率语言模型如何突破人类思维边界?

颠覆语言认知的革命&#xff01;神经概率语言模型如何突破人类思维边界&#xff1f; 一、传统模型的世纪困境&#xff1a;当n-gram遇上"月光族难题" 令人震惊的案例&#xff1a;2012年Google语音识别系统将 用户说&#xff1a;“我要还信用卡” 系统识别&#xff…

练习:关于静态路由,手工汇总,路由黑洞,缺省路由相关

这是题目,我已经画分好了网段,题目要求是这样的: 划分网段 我为什么一个网段划了6个可用IP(一个网段8个地址)呢,因为我刚开始吧环回接口理解成一个主机了,导致我认为两个环回主机在一个网段,其实每个网段只需要2个地址就可以完成这个练习,我懒得划了,就按第一张图的网段来吧…

J6打卡——pytorch实现ResNeXt-50实现猴痘检测

&#x1f368; 本文为&#x1f517;365天深度学习训练营中的学习记录博客 &#x1f356; 原作者&#xff1a;K同学啊 1.检查GPU import torch import torch.nn as nn import torchvision.transforms as transforms import torchvision from torchvision import transforms, d…

vue+dhtmlx-gantt 实现甘特图-快速入门【甘特图】

文章目录 一、前言二、使用说明2.1 引入依赖2.2 引入组件2.3 引入dhtmlx-gantt2.4 甘特图数据配置2.5 初始化配置 三、代码示例3.1 Vue2完整示例3.2 Vue3 完整示例 四、效果图 一、前言 dhtmlxGantt 是一款功能强大的甘特图组件&#xff0c;支持 Vue 3 集成。它提供了丰富的功…

音视频入门基础:RTP专题(16)——RTP封装音频时,音频的有效载荷结构

一、引言 《RFC 3640》和《RFC 6416》分别定义了两种对MPEG-4流的RTP封包方式&#xff0c;这两个文档都可以从RFC官网下载&#xff1a; RFC Editor 本文主要对《RFC 3640》中的音频打包方式进行简介。《RFC 3640》总共有43页&#xff0c;本文下面所说的“页数”是指在pdf阅读…

超分之DeSRA

Desra: detect and delete the artifacts of gan-based real-world super-resolution models.DeSRA&#xff1a;检测并消除基于GAN的真实世界超分辨率模型中的伪影Xie L, Wang X, Chen X, et al.arXiv preprint arXiv:2307.02457, 2023. 摘要 背景&#xff1a; GAN-SR模型虽然…

Ubuntu用户安装cpolar内网穿透

前言 Cpolar作为一款体积小巧却功能强大的内网穿透软件&#xff0c;不仅能够在多种环境和应用场景中发挥巨大作用&#xff0c;还能适应多种操作系统&#xff0c;应用最为广泛的Windows、Mac OS系统自不必多说&#xff0c;稍显小众的Linux、树莓派、群辉等也在起支持之列&#…

小程序事件系统 —— 33 事件传参 - data-*自定义数据

事件传参&#xff1a;在触发事件时&#xff0c;将一些数据作为参数传递给事件处理函数的过程&#xff0c;就是事件传参&#xff1b; 在微信小程序中&#xff0c;我们经常会在组件上添加一些自定义数据&#xff0c;然后在事件处理函数中获取这些自定义数据&#xff0c;从而完成…

【Java学习】包装类

面向对象系列九 包装类变量 一、装箱 1.实例化包装对象 2.静态缓存池 3.写法 二、拆箱 包装类变量 每个基本数据类型都有对应的基本类型的包装类变量&#xff0c;将基本数据类型通过对应的包装类对象载入着进入到类与对象面向对象体系 一、装箱 Integer.valueOf(int) —…

中国自动化领域零部件研究报告

一、引言 1.1 研究背景与目的 随着科技的飞速发展&#xff0c;自动化技术已成为推动各行业转型升级的关键力量。中国自动化领域零部件行业在近年来取得了显著进展&#xff0c;市场规模持续扩大&#xff0c;技术水平不断提升。在政策支持与市场需求的双重驱动下&#xff0c;中…

MySQL数据集成:高效数据同步与监控

MySQL数据集成案例分享&#xff1a;user-钉钉部门树-名称刷新 在企业信息系统中&#xff0c;数据的高效流动和准确同步是确保业务连续性和决策支持的重要环节。本文将聚焦于一个具体的系统对接集成案例——将MySQL中的数据集成到另一个MySQL数据库中&#xff0c;方案名称为“u…