当前位置: 首页 > article >正文

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

文章目录

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


前言

本文为《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; // Applecout << "查找11: " << (ht.find(11, value) ? value : "Not Found") << endl; // Bananacout << "查找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 Foundht.remove(1);cout << "删除头节点后查找1: " << (ht.find(1, value) ? value : "Not Found") << endl; // Not Foundcout << "删除后查找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](); // 动态分配并初始化为0hash = 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; // Alicecout << "Key 999 -> " << (ht.find(999, value) ? value : "Not Found") << endl; // Not Foundcout << "\n===== 测试2:键值更新 =====" << endl;ht.insert(202, "Bobby");  // 更新已有键ht.find(202, value);cout << "Key 202 -> " << value << endl; // Bobbycout << "\n===== 测试3:哈希冲突处理 =====" << endl;ht.insert(7, "Conflict1");  // 7 % 7 = 0ht.insert(14, "Conflict2"); // 14 % 7 = 0cout << "Bucket 0 查找测试:" << endl;cout << "Key 7 -> " << (ht.find(7, value) ? value : "Not Found") << endl;    // Conflict1cout << "Key 14 -> " << (ht.find(14, value) ? value : "Not Found") << endl;  // Conflict2cout << "\n===== 测试4:删除操作 =====" << endl;ht.remove(202);cout << "删除后查找202 -> " << (ht.find(202, value) ? value : "Not Found") << endl; // Not Foundcout << "\n===== 测试5:负数键处理 =====" << endl;ht.insert(-5, "Negative");  // (-5 % 7 + 7) = 2cout << "Key -5 -> " << (ht.find(-5, value) ? value : "Not Found") << endl;  // Negativereturn 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:90student_scores["Bob"] = 85;     // 插入 Bob:85// 方法2: 使用 insert 插入(若键存在则不会覆盖)student_scores.insert({"Charlie", 88});  // 插入 Charlie:88student_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;
}

四、哈希表的总结

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


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

相关文章:

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

文章目录 前言一、哈希表的模板代码二、哈希计数器三、哈希表中的无序映射四、哈希表的总结 前言 本文为《C学习》的第11篇文章&#xff0c;今天学习最后一个数据结构哈希表&#xff08;散列表&#xff09;。 一、哈希表的模板代码 #include<iostream> using namespace…...

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…...

数据结构:有序表的插入

本文是我编写的针对计算机专业考研复习《数据结构》所用资料内容选刊。主要目的在于向复习这门课程的同学说明&#xff0c;此类问题不仅仅使用顺序表&#xff0c;也可以使用链表。并且&#xff0c;在复习中&#xff0c;两种数据结构都要掌握。 若线性表中的数据元素相互之间可以…...

【医院内部控制专题】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使…...

Spring 面向切面编程 XML 配置实现

Spring 支持AOP &#xff0c;并且可以通过XML配置来实现。 <beans xmlns"http://www.springframework.org/schema/beans"xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xmlns:aop"http://www.springframework.org/schema/aop"xmlns:…...

【Pandas】pandas Series compare

# Pandas2.2 Series ## Computations descriptive stats |方法|描述| |-|:-------| |Series.compare(other[, align_axis, ...])|用于比较两个 Series| ### pandas.Series.compare pandas.Series.compare 方法用于比较两个 Series&#xff0c;并返回一个包含差异的 DataFram…...

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

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

【实战ES】实战 Elasticsearch:快速上手与深度实践-5.1.1热点分片识别与均衡策略

&#x1f449; 点击关注不迷路 &#x1f449; 点击关注不迷路 &#x1f449; 点击关注不迷路 文章大纲 5.1.1 Filebeat Logstash ES Kibana 全链路配置实1. 架构设计与组件选型1.1 技术栈对比分析1.2 硬件配置推荐 2. Filebeat 高级配置2.1 多输入源配置2.2 性能优化参数 3.…...

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

这是题目,我已经画分好了网段,题目要求是这样的: 划分网段 我为什么一个网段划了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阅读…...

通领科技冲刺北交所

高质量增长奔赴产业新征程 日前&#xff0c;通领科技已正式启动在北交所的 IPO 进程&#xff0c;期望借助资本市场的力量&#xff0c;加速技术升级&#xff0c;推动全球化战略布局。这一举措不仅展现了中国汽车零部件企业的强大实力&#xff0c;也预示着行业转型升级的新突破。…...

超分之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;中…...

Neo4j 数据库备份

将包括系统数据库在内的所有数据库的最近备份存储在一个安全的位置是非常重要的。这确保了在发生数据丢失或损坏时&#xff0c;能够迅速恢复数据库到最近的状态&#xff0c;减少可能的业务影响。对于不同的数据库环境&#xff08;开发、测试或生产&#xff09;&#xff0c;根据…...

【每日学点HarmonyOS Next知识】span问题、组件标识属性、属性动画回调、图文混排、相对布局问题

1、HarmonyOS 如果有两个span 第一个span放的是中文 第二个span超长 这时候 Ellipsis会展示异常&#xff1f; 如果有两个span 第一个span放的是中文 第二个span超长 这时候 Ellipsis会展示异常 设置断行规则.wordBreak(WordBreak.BREAK_ALL)即可。 参考连接&#xff1a;http…...

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

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

时序数据库TimescaleDB基本操作示例

好的&#xff01;以下是使用 TimescaleDB 的 Java 示例&#xff08;基于 JDBC&#xff0c;因为 TimescaleDB 是 PostgreSQL 的扩展&#xff0c;官方未提供独立的 Java SDK&#xff09;&#xff1a; 1. 添加依赖&#xff08;Maven&#xff09; <dependency><groupId&g…...

【VBA】WPS/PPT设置标题字体

通过VBA&#xff0c;配合左上角的快速访问工具栏&#xff0c;实现自动化调整 选中文本框的 字体位置、大小、颜色。 配合quicker更加便捷 Sub DisableAutoWrapAndFormat()Dim shp As Shape 检查是否选中了一个形状&#xff08;文本框&#xff09;If ActiveWindow.Selection.Typ…...