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

QT6 源(34):随机数生成器类 QRandomGenerator 的源码阅读

(1)代码来自 qrandom.h ,结合官方的注释

#ifndef QRANDOM_H
#define QRANDOM_H#include <QtCore/qalgorithms.h>
#include <algorithm>    // for std::generate
#include <random>       // for std::mt19937#ifdef min
#  undef min
#endif
#ifdef max
#  undef max
#endifQT_BEGIN_NAMESPACE  //说明本类直接定义在 QT 的命名空间class QRandomGenerator //Note: All functions in this class are reentrant.
{// restrict the template parameters to// unsigned integers 32 bits wide or larger// 为 true 时要求模板参数 UINT 在 32bit 以上template <typename UInt> //定义模板变量,本值是布尔量using IfValidUInt = typename std::enable_if<std::is_unsigned<UInt>::value &&sizeof(UInt) >= sizeof(uint), bool>::type;private: //私有部分会包含重要的数据成员的定义//typedef  QIntegerForSizeof<void *>::Signed  qptrdiff;Q_CORE_EXPORT quint64 _fillRange(void *buffer, qptrdiff count);//应该是从 buffer 地址开始填充 count 个随机数struct InitialRandomData { //本类用作下面的友元函数的返回值类型//typedef QIntegerForSizeof<void *>::Unsigned quintptr;quintptr data[16 / sizeof(quintptr)]; //sizeof(quintptr) = 8};friend InitialRandomData qt_initial_random_value() noexcept; //友元函数friend class QRandomGenerator64 ; //友元类struct SystemGenerator          ; //类声明struct SystemAndGlobalGenerators;using RandomEngine = std::mersenne_twister_engine< //模板别名quint32, 32,624,397,31,0x9908b0df,11,0xffffffff,7,0x9d2c5680,15,0xefc60000,18,1812433253>;union Storage //定义了类中类{uint dummy ;           //本类的数据成员
#ifdef Q_COMPILER_UNRESTRICTED_UNIONS //if分支有效RandomEngine twister;  //本类的成员变量RandomEngine & engine()       { return twister; }const RandomEngine & engine() const { return twister; }
#else                                 //else分支作废std::aligned_storage<sizeof(RandomEngine), alignof(RandomEngine)>::type buffer;RandomEngine &engine() { return reinterpret_cast<RandomEngine &>(buffer); }const RandomEngine &engine() const { return reinterpret_cast<const RandomEngine &>(buffer); }
#endifstatic_assert(std::is_trivially_destructible<RandomEngine>::value,"std::mersenne_twister not trivially平凡地 destructible as expected");constexpr Storage(); //本类的默认构造函数};Storage storage; //本随机类的数据成员uint    type   ; //又一个数据成员public://Initializes this QRandomGenerator object with the value seedValue//as the seed. Two objects constructed or reseeded with the same seed value//will produce the same number sequence.QRandomGenerator(quint32 seedValue = 1)  //本类的有参构造函数: QRandomGenerator(&seedValue, 1) {} //带默认参数,也可以作为无参构造函数//Initializes this QRandomGenerator object//with the values found in the array seedBuffer as the seed.//Two objects constructed or reseeded with the same seed value//will produce the same number sequence.//可以这么用: uint t[3]={1,2,3};  //此处必须是无符号数组, int 数组会报错//      QRandomGenerator ma(t);template <qsizetype N> //普通类型的模板参数,必须给值的QRandomGenerator(const quint32 (&seedBuffer)[N]) //形参是整型数组: QRandomGenerator(seedBuffer, seedBuffer + N) {}//Initializes this QRandomGenerator object//with len values found in the array seedBuffer as the seed.QRandomGenerator(const quint32 * seedBuffer, qsizetype len): QRandomGenerator(seedBuffer, seedBuffer + len) {}Q_CORE_EXPORT QRandomGenerator(std::seed_seq & sseq) noexcept;//构造函数//Initializes this QRandomGenerator object//with the values found in the range from begin to end as the seed.Q_CORE_EXPORT QRandomGenerator(const quint32 *begin, const quint32 *end);//本类的静态成员函数,返回一个指针,指向随机数生成器对象。英文注释讲解略//返回一个指向共享ORandomGenerator的指针,//该共享ORandomGenerator总是使用操作系统提供的工具来生成随机数。//系统设施在至少以下操作系统上被认为是加密安全的:苹果操作系统(Darwin)、BSD、//Linux、Windows。在其他操作系统上也可能出现这种情况。//他们也可能支持一个真正的硬件随机数发生器。//因此,此函数返回的ORandomGenerator不应用于批量数据生成。//相反,可以用它从<random>头部种子化ORandomGenerator或一个随机引擎。//此函数返回的对象是线程安全的,可以在任何线程中使用,无需锁定。//它也可以被复制,生成的 ORandomGenerator也会访问操作系统设施,但它们不会生成相同的序列。static inline Q_DECL_CONST_FUNCTION QRandomGenerator * system();//老师说不要用这个函数大量生成随机数据,只用来生成种子即可。!!!!++++//返回一个共享的QRandomGenerator的指针,该指针使用securelySeeded()进行初始化。//此函数应用于创建随机数据,//而无需为特定用途创建昂贵的securely-seeded ORandomGenerator//或存储较大的 QRandomGenerator对象。//对这个对象的访问是线程安全的,因此可以在任何线程中使用,无需锁定。//该对象也可以被复制,而复制产生的序列将与共享对象产生的序列相同。//但是,请注意,如果有其他线程访问全局对象,这些线程可能会在不可预测的间隔内获取样本。static inline Q_DECL_CONST_FUNCTION QRandomGenerator * global();//返回指针//老师说,一般情况用这个静态函数就足够了。!!!!!++++++//返回一个新的 QRandomGenerator 对象,该对象通过 QRandomGenerator:system()//安全地进行了初始化。此函数将为 ORandomGenerator 使用的算法获取理想的种子大小,//因此是创建将保留-段时间的新 ORandomGenerator 对象的推荐方法。//考虑到安全启动确定性引擎所需的数据量,这个函数有些昂贵,//不应用于QRandomGenerator 的短期使用//(使用它生成少于 2600 字节的随机数据实际上是一种资源浪费)。//如果使用不需要那么多数据,可以考虑使用 ORandomGenerator::global()//而不是存储一个 ORandomGenerator 对象。static inline QRandomGenerator securelySeeded();  //返回生成器对象// copy constructor & assignment operator (move unnecessary)Q_CORE_EXPORT QRandomGenerator(const QRandomGenerator &other);//copy 构造函数与 copy 赋值运算符函数Q_CORE_EXPORT QRandomGenerator & operator=(const QRandomGenerator & other);friend Q_CORE_EXPORT bool //声明了全局友元函数operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2);friend bool operator!=(const QRandomGenerator &rng1,const QRandomGenerator &rng2  ){return !(rng1 == rng2);}//Generates a 32-bit random quantity数量 and returns it.//调用了本类的私有成员函数 _fillRange()以实现本函的功能quint32 generate() { return quint32(_fillRange(nullptr, 1));  }//Generates a 64-bit random quantity and returns it.quint64 generate64(){return _fillRange(nullptr, sizeof(quint64) / sizeof(quint32));}//Generates one random qreal in the canonical range [0, 1)//(that is, inclusive of zero and exclusive of 1).double generateDouble(){// IEEE 754 double precision has: 双精度数值,共 64 bit 8字节//   1 bit      sign//  10 bits     exponent  指数部分//  53 bits     mantissa  有效数字// In order for our result to be normalized in the range [0, 1), we// need exactly 53 bits of random data. Use generate64() to get enough.quint64     x = generate64();quint64 limit = Q_UINT64_C(1) << std::numeric_limits<double>::digits;x >>= std::numeric_limits<quint64>::digits - //这是个减法运算std::numeric_limits<double> ::digits ;return double(x) / double(limit);}//Generates 32-bit quantities and stores them//in the range between begin and end.// API like std::seed_seqtemplate <typename ForwardIterator>void generate(ForwardIterator begin, ForwardIterator end){std::generate(begin, end, [this]() { return generate(); });}void generate(quint32 *begin, quint32 *end){_fillRange(begin, end - begin);}//generate 与 bound 差不多,前者的取值不受限制,后者有突出边界上限的意思。//Generates one random double in the range between 0 (inclusive) and//highest (exclusive).//This function is equivalent to and is implemented as://     return generateDouble() * highest; 此行是本函数的实现原理//If the highest parameter is negative,//the result will be negative too;//if it is infinite or NaN,//the result will be infinite or NaN too (that is, not random).double bounded(double highest) //形参是 double 类型{return generateDouble() * highest;}//typedef unsigned int quint32;quint32 bounded(quint32 highest) //形参是 32 位无符号整数{quint64 value = generate();value *= highest;            //先乘法后除法才不会损失精度value /= (max)() + quint64(1);return quint32(value);}//Generates one random 32-bit quantity in the range between 0 (inclusive)//and highest (exclusive). highest must be positive.int bounded(int highest)    //函数重载{Q_ASSERT(highest > 0);return int(bounded(0U, quint32(highest)));}qint64 bounded(qint64  highest) //形参的无符号与有符号版本{Q_ASSERT(highest > 0);return qint64(bounded(quint64(0), quint64(highest)));}quint64 bounded(quint64 highest);//Generates one random 32-bit quantity in the range between//lowest (inclusive) and highest (exclusive).//The highest parameter must be greater than lowest.quint32 bounded(quint32 lowest, quint32 highest){Q_ASSERT(highest > lowest);return bounded(highest - lowest) + lowest;}int bounded(int lowest, int highest){return bounded(highest - lowest) + lowest;}quint64 bounded(quint64 lowest, quint64 highest){Q_ASSERT(highest > lowest);return bounded(highest - lowest) + lowest;}qint64 bounded(qint64 lowest, qint64 highest){return bounded(highest - lowest) + lowest;}// these functions here only to help with ambiguous overloadsqint64 bounded(int lowest, qint64 highest){return bounded(qint64(lowest), qint64(highest));}qint64 bounded(qint64 lowest, int highest){return bounded(qint64(lowest), qint64(highest));}quint64 bounded(unsigned lowest, quint64 highest){return bounded(quint64(lowest), quint64(highest));}quint64 bounded(quint64 lowest, unsigned highest){return bounded(quint64(lowest), quint64(highest));}//Generates count 32- or 64-bit quantities (depending on the type UInt)//and stores them in the buffer pointed by buffer.//This is the most efficient way to obtain more than one quantity at a time,//as it reduces the number of calls into the Random Number Generator source.template <typename UInt, IfValidUInt<UInt> = true>void fillRange(UInt * buffer, qsizetype count){_fillRange(buffer, count * sizeof(UInt) / sizeof(quint32));}//Generates N 32- or 64-bit quantities (depending on the type UInt)//and stores them in the buffer array.template <typename UInt, size_t N, IfValidUInt<UInt> = true>void fillRange(UInt (&buffer)[N]) //形参是数组名的类型,N由模板参数确定了{_fillRange(buffer, N * sizeof(UInt) / sizeof(quint32));}// API like std:: random enginestypedef quint32 result_type; //重载了括号 () 运算符,使本类成为了可调用对象result_type operator()() { return generate(); }//Reseeds this object using the value seed as the seed.void seed(quint32 s = 1) { *this = { s }; }void seed(std::seed_seq & sseq) noexcept { *this = { sseq }; }//Discards the next z entries from the sequence.//This method is equivalent to calling generate() z times//and discarding the result, 形参是丢掉 z 个随机数Q_CORE_EXPORT void discard(unsigned long long z);//Returns the minimum value that QRandomGenerator may ever generate.//That is, 0.static constexpr result_type min(){ return std::numeric_limits<result_type>::min(); }//Returns the maximum value that QRandomGenerator may ever generate.//That is, std::numeric_limits<result_type>::max().static constexpr result_type max(){ return std::numeric_limits<result_type>::max(); }protected:enum System {}; //本类的 protected 属性的成员函数QRandomGenerator(System); //这是一个构造函数};class QRandomGenerator64 : public QRandomGenerator //子类的 64 bit 生成器
{QRandomGenerator64(System);
public:// unshadow generate() overloads, since we'll override.using QRandomGenerator::generate;quint64 generate() { return generate64(); }typedef quint64 result_type;result_type operator()() { return generate64(); }#ifndef Q_QDOCQRandomGenerator64(quint32 seedValue = 1): QRandomGenerator(seedValue) {}template <qsizetype N>QRandomGenerator64(const quint32 (&seedBuffer)[N]): QRandomGenerator(seedBuffer) {}QRandomGenerator64(const quint32 *seedBuffer, qsizetype len): QRandomGenerator(seedBuffer, len) {}QRandomGenerator64(std::seed_seq &sseq) noexcept: QRandomGenerator(sseq) {}QRandomGenerator64(const quint32 *begin, const quint32 *end): QRandomGenerator(begin, end) {}QRandomGenerator64(const QRandomGenerator &other): QRandomGenerator(other) {}void discard(unsigned long long z){Q_ASSERT_X(z * 2 > z, "QRandomGenerator64::discard","Overflow. Are you sure you want to skip over 9 quintillion samples?");QRandomGenerator::discard(z * 2);}static constexpr result_type min(){ return std::numeric_limits<result_type>::min(); }static constexpr result_type max(){ return std::numeric_limits<result_type>::max(); }static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *system();static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *global();static Q_CORE_EXPORT QRandomGenerator64 securelySeeded();
#endif // Q_QDOC
};inline quint64 QRandomGenerator::bounded(quint64 highest)
{// Implement an algorithm similar to libc++'s uniform_int_distribution:// loop around getting a random number, mask off any bits that "highest"// will never need, then check if it's higher than "highest". The number of// times the loop will run is unbounded but the probability of terminating// is better than 1/2 on each iteration. Therefore, the average loop count// should be less than 2.const int width = qCountLeadingZeroBits(highest - 1);const quint64 mask = (quint64(1) << (std::numeric_limits<quint64>::digits - width)) - 1;quint64 v;do {v = generate64() & mask;} while (v >= highest);return v;
}inline QRandomGenerator * QRandomGenerator::system()
{   //本函利用系统资源生成随机数生成器return QRandomGenerator64::system();
}inline QRandomGenerator * QRandomGenerator::global()
{return QRandomGenerator64::global();
}//由这里可见,子类的 64 bit的随机数生成器更重要,更基础。QRandomGenerator QRandomGenerator::securelySeeded()
{return QRandomGenerator64::securelySeeded();
}QT_END_NAMESPACE#endif // QRANDOM_H

(2)

谢谢

相关文章:

QT6 源(34):随机数生成器类 QRandomGenerator 的源码阅读

&#xff08;1&#xff09;代码来自 qrandom.h &#xff0c;结合官方的注释&#xff1a; #ifndef QRANDOM_H #define QRANDOM_H#include <QtCore/qalgorithms.h> #include <algorithm> // for std::generate #include <random> // for std::mt1993…...

极狐GitLab GEO 功能介绍

极狐GitLab 是 GitLab 在中国的发行版&#xff0c;关于中文参考文档和资料有&#xff1a; 极狐GitLab 中文文档极狐GitLab 中文论坛极狐GitLab 官网 Geo (PREMIUM SELF) Geo 是广泛分布的开发团队的解决方案&#xff0c;可作为灾难恢复策略的一部分提供热备份。Geo 不是 开箱…...

快速上手,OceanBase + MCP + LLM,搭建 AI 应用

在 AI 技术发展的进程中&#xff0c;大语言模型&#xff08;LLM&#xff09;凭借卓越的信息处理与推理能力广受重视。然而&#xff0c;数据孤岛问题仍是 LLM 面临的核心挑战。目前&#xff0c;LLM 的推理主要依赖于预先训练的数据和有限的上下文窗口&#xff0c;既无法动态访问…...

【Python爬虫基础篇】--1.基础概念

目录 1.爬虫--定义 2.爬虫--组成 3.爬虫--URL 1.爬虫--定义 网络爬虫&#xff0c;是一种按照一定规则&#xff0c;自动抓取互联网信息的程序或者脚本。另外一些不常使用的名字还有蚂蚁、自动索引、模拟程序或者蠕虫。随着网络的迅速发展&#xff0c;万维网成为大量信息的载体…...

Linux :进程替换

进程替换 &#xff08;一&#xff09;进程程序替换1.替换原理2.替换函数exec函数命名理解 &#xff08;二&#xff09;实现简易shell &#xff08;一&#xff09;进程程序替换 1.替换原理 用fork创建子进程后执行的是和父进程相同的程序(但有可能执行不同的代码分支),子进程往…...

XC7K410T‑2FFG900I 赛灵思XilinxFPGA Kintex‑7

XC7K410T‑2FFG900I Xilinx 赛灵思FPGA Kintex‑7 系列定位&#xff1a;Kintex‑7 中端&#xff0c;高性价比与高性能平衡 工艺节点&#xff1a;28 nm HPL&#xff08;High‑Performance, Low‑Power&#xff09;HKMG&#xff08;High‑κ Metal Gate&#xff09; 逻辑资源&…...

list容器介绍及模拟实现和与vector比较

目录 list容器介绍 lisy接口 list迭代器的注意事项 迭代器失效 list的模拟实现 list的节点 list的迭代器实现 list的接口实现 vector和list的优缺点 vector优点&#xff1a; vector缺点&#xff1a; list优点&#xff1a; list缺点&#xff1a; 总结&#xff1a; …...

[图论]Prim

Prim 本质&#xff1a;BFS贪心&#xff0c;对点进行操作。与最短路Dijkstra算法是“孪生兄弟”。存储结构&#xff1a;链式前向星适用对象&#xff1a;可为负权图&#xff0c;可求最大生成树核心思想&#xff1a;最近的邻接点一定在最小生成树(MST)上&#xff0c;对点的最近邻…...

【python】pysharm常用快捷键使用-(1)

*1.格式化代码【Ctrl Alt L】 写代码的时候会有很多黄色的波浪号&#xff08;如图&#xff09;又叫蚂蚁线&#xff0c;可以点击任意黄色波浪号的代码&#xff0c;然后按下【Ctrl Alt L】进行代码格式化。 2.添加函数功能和参数注释 添加函数文档字符串 docstring 在函数…...

06-DevOps-自动构建Docker镜像

前面已经完成了jar文件的打包和发布&#xff0c;但在实际使用时&#xff0c;可能会遇到外部依赖环境发生改变&#xff0c;为了解决这些问题&#xff0c;更多的做法是把应用程序以docker镜像&#xff0c;生成容器的方式运行&#xff0c;这是一种标准化的方式。 创建Dockerfile文…...

案例驱动的 IT 团队管理:创新与突破之路:第五章 创新管理:从机制设计到文化养成-5.2 技术决策民主化-5.2.2技术选型的量化评估矩阵

&#x1f449; 点击关注不迷路 &#x1f449; 点击关注不迷路 &#x1f449; 点击关注不迷路 文章大纲 案例驱动的 IT 团队管理&#xff1a;创新与突破之路 - 第五章 创新管理&#xff1a;从机制设计到文化养成 - 5.2 技术决策民主化5.2.2 技术选型的量化评估矩阵一、技术选型的…...

力扣面试150题--有效的字母异位词和字母异位词分组

Day 24 题目描述 思路 初次思路&#xff1a;如果两个字符串为异位词&#xff0c;说明它们长度相同并且字母出现的次数相同&#xff0c;于是有以下做法&#xff1a; 定义一个map&#xff0c;来保存s中每个字符的出现次数处理特殊情况&#xff0c;如果长度不同&#xff0c;直接…...

WSL2-Ubuntu22.04安装URSim5.21.3

WSL2-Ubuntu22.04安装URSim5.21.3 准备安装启动 准备 名称版本WSL2Ubuntu22.04URSim5.21.3VcXsrvNaN WSL2安装与可视化请见这篇:WSL2-Ubuntu22.04-配置。 安装 我们是wsl2-ubuntu22.04&#xff0c;所以安装Linux版本的URSim&#xff0c;下载之前需要注册一下&#xff0c;即…...

配合 Spring Bean 注入,把 Function 管理起来?

大家好呀&#xff01;今天我们来聊聊一个特别有意思的话题 - 如何在Spring中优雅地管理和注入Function对象。就像把各种调料整齐地摆在厨房里一样&#xff0c;我们要把各种函数方法也管理得井井有条&#xff01;&#x1f373; 一、为什么要把Function管起来&#xff1f;&#…...

Wireshark TS | 异常 ACK 数据包处理

问题背景 来自于学习群里群友讨论的一个数据包跟踪文件&#xff0c;在其中涉及到两处数据包异常现象&#xff0c;而产生这些现象的实际原因是数据包乱序。由于这两处数据包异常&#xff0c;都有点特别&#xff0c;本篇也就其中一个异常现象单独展开说明。 问题信息 数据包跟…...

vue3 el-dialog新增弹窗,不希望一进去就校验名称没有填写

就是在进入弹窗时、点击关闭/取消按钮时等情况清空该表单校验&#xff0c;在失去焦点或者点击确定/提交按钮的时候再去校验。这里默认已经写好了在失去焦点或者点击确定/提交按钮的时候的校验逻辑。 解决步骤&#xff1a; 一、定义清空表单校验方法 // 清空表单校验const cle…...

【2-12】CRC循环冗余校验码

前言 前面我们介绍了纠错码——海明码&#xff0c;同时还说明了为什么现代网络常用检错重传而不是纠错&#xff0c;本文介绍CRC循环冗余校验码。 文章目录 前言1. 简单定义2. 生成规则3. 例题3.1 例13.2 例2 后记修改记录 1. 简单定义 CRC&#xff08;Cyclic Redundancy Chec…...

多 Agent 协作怎么整:从谷歌A2A到多Agent交互方案实现

写在前面:多 Agent 协作模式 大型语言模型(LLM)的浪潮之下,能够自主理解、规划并执行任务的 AI Agent(智能体)正成为人工智能领域最炙手可热的焦点。我们惊叹于单个 Agent 展现出的强大能力,但当面对日益复杂的现实世界任务时,单个 Agent 的局限性也逐渐显现。 正如人…...

内部聊天软件,BeeWorks-安全的企业内部通讯软件

企业在享受数据便利的同时&#xff0c;如何保障企业数据安全已经成为无法回避的重要课题。BeeWorks作为一款专为企业设计的内部通讯软件&#xff0c;通过全链路的安全能力升维&#xff0c;为企业提供了一个安全、高效、便捷的沟通协作平台&#xff0c;全面保障企业数据安全。 …...

健康养生:开启活力生活的密钥

当我们在健身房看到年逾六旬却身形矫健的老人&#xff0c;在公园偶遇精神矍铄、步伐轻快的长者&#xff0c;总会惊叹于他们的健康状态。其实&#xff0c;这些都得益于长期坚持科学的养生之道。健康养生并非遥不可及的玄学&#xff0c;而是融入生活细节的智慧。​ 在饮食的世界…...

士兵乱斗(贪心)

问题 B: 士兵乱斗 - USCOJ...

Android 不插SIM卡,手机不能拨打紧急电话;2g+gsm配置才支持112紧急拨号

[DESCRIPTION] 不插SIM卡&#xff0c;手机不能拨打紧急电话 Root Cause 手机没有写入合法的IMEI;或者当地的某个运营商不支持紧急电话&#xff0c;而手机正好选上了这个运营商;或者当地的某个运营商不支持无SIM卡的紧急电话&#xff0c;而手机正好选上了这个运营商 [SOLUTION] …...

Freertos----信号量

一、信号量的特性&#xff1a; 生产者为任务A、B&#xff0c;消费者为任务C、D一开始信号量的计数值为0&#xff0c;如果任务C、D想获得信号量&#xff0c;会有两种结果&#xff1a; 阻塞&#xff1a;买不到东西咱就等等吧&#xff0c;可以定个闹钟(超时时间)即刻返回失败&…...

AI 数字短视频数字人源码开发的多元价值与深远意义​

在短视频行业竞争日益激烈的当下&#xff0c;AI 数字短视频数字人源码开发正以颠覆性的姿态&#xff0c;为行业带来诸多前所未有的优势&#xff0c;从创作、传播到商业变现等环节&#xff0c;全面重塑短视频生态。​ 创新创作模式&#xff0c;激发无限创意​ 传统短视频创作受…...

Apifox下载安装与使用

一、Apifox下载 官网地址:Apifox 点击"免费下载",即可进行下载。 二、Apifox安装 双击安装文件即可安装。...

命令行参数解析 - argparse 模块

1、简介 argparse 模块是 Python 标准库中提供的一个 命令行解析模块 &#xff0c;它可以让使用者以类似 Unix/Linux 命令参数的方式输入参数&#xff08;在终端以命令行的方式指定参数&#xff09;&#xff0c;argparse 会自动将命令行指定的参数解析为 Python 变量&#xff…...

【Android】 如何将 APK 内置为系统应用(适用于编辑设置属性)

如何将 APK 内置为系统应用(适用于编辑设置属性) 在 Android 中&#xff0c;将 APK 文件内置为系统应用涉及到一系列的命令和步骤。以下是详细的操作流程&#xff0c;帮助您解决常见问题&#xff0c;如 /system not in /proc/mounts 的错误。 挂载system/app获取可读写权限 …...

随手笔记-python-opencv 读取图像的顺序 与pytorch处理图像的顺序

import cv2# 读取图像 image_path path/to/your/image.jpg # 替换为你的图像路径 image cv2.imread(image_path)# 检查图像是否成功读取 if image is None:print("Error: Unable to load image.") else:print("Image loaded successfully.") 1、OpenCV…...

996引擎-实战笔记:Lua 的 NPC 面板获取 Input 内容

996引擎-实战笔记:Lua 的 NPC 面板获取 Input 内容 获取 Input 内容测试NPC参考资料获取 Input 内容 测试NPC -- NPC入口函数 function main(player)local msg = [[<Img|id=9527|x=0|y=0|width=300|height=150|img=public/bg_npc_01.png|bg=1|move=1|reset=1|show=0|layer…...

少数服从多数悖论、黑白颠倒与众人孤立现象之如何应对(一)

观己之前&#xff0c;也可先观众生 如果当时没有袖手旁观&#xff0c;或许唇不亡齿也不会寒 ■如何轻松/更好应对个别被众人孤立&#xff08;他人、辨别、自己&#xff09; ●他人被孤立 不参与 有余力&#xff0c;助弱者 被孤立者本身有问题 •不参与&#xff1a;不会辨…...

大模型在急性单纯性阑尾炎预测及治疗方案制定中的应用研究

目录 一、引言 1.1 研究背景与意义 1.2 研究目的 1.3 研究方法与创新点 二、急性单纯性阑尾炎概述 2.1 定义与发病机制 2.2 临床表现 2.3 传统诊断方法 三、大模型在急性单纯性阑尾炎预测中的应用 3.1 大模型简介 3.2 数据收集与处理 3.3 模型训练与优化 3.4 预测…...

科研新触角:松灵六轴臂重构具身智能生态

在具身智能&#xff08;Embodied AI&#xff09;从实验室走向产业化的进程中&#xff0c;硬件性能与场景适配性成为技术落地的核心瓶颈。松灵机器人推出的全自研科研级轻量六轴机械臂PiPER&#xff0c;以“轻量化设计毫米级精度跨平台兼容”三大技术突破&#xff0c;重新定义了…...

第四讲 感应熔炼电炉设计和感应器参数计算(中)

第四讲 感应熔炼电炉设计和感应器参数计算&#xff08;中&#xff09; 目录 第四讲 感应熔炼电炉设计和感应器参数计算&#xff08;中&#xff09;磁轭、短路环、消磁环、水冷圈的设计1. 磁轭的设计1.1 磁轭的作用1.2 磁轭的材料1.3 磁轭截面设计1.4 磁轭高度的确定1.5 磁轭总重…...

【Contiki】Contiki源码目录结构

00. 目录 文章目录 00. 目录01. 概述02. Contiki目录结构03. apps目录04. core目录05. CPU目录06. doc目录07. examples目录08. platform目录09. regression-tests目录10. tools目录11. 附录 01. 概述 Contiki是一款开源操作系统&#xff0c;专为微小的低功耗微控制器设计&…...

第五章 SQLite数据库:3、SQLite 常用语法及使用案例

SQLite Insert 语句 SQLite 的 INSERT INTO 语句用于向表中添加新数据行。 语法 INSERT INTO 有两种常见语法形式&#xff1a; 使用列名指定要插入的列&#xff1a; -- 插入数据并指定列名 INSERT INTO TABLE_NAME (column1, column2, ..., columnN) VALUES (value1, va…...

【安卓开发】【Android Studio】Menu(菜单栏)的使用及常见问题

一、菜单栏选项 在项目中添加顶部菜单栏的方法&#xff1a; 在res目录下新建menu文件夹&#xff0c;在该文件夹下新建用于菜单栏的xml文件&#xff1a; 举例说明菜单栏的写法&#xff0c;只添加一个选项元素&#xff1a; <?xml version"1.0" encoding"ut…...

web-ssrfme

SSRF漏洞 SSRF是Server-Side Request Forgery&#xff08;服务器端请求伪造&#xff09;的缩写&#xff0c;是一种网络攻击技术。攻击者发送恶意请求给目标服务器&#xff0c;让服务器去访问攻击者指定的其他服务器或者域名&#xff0c;从而获取敏感信息或者攻击其他系统。 S…...

Linux:进程:进程状态

进程是一个负责分配系统资源&#xff08;CPU时间&#xff0c;内存&#xff09;的实体。 进程内核数据结构&#xff08;用于描述和组织进程&#xff09;代码数据&#xff08;实际内容&#xff09; 描述进程-PCB 进程信息被放在⼀个叫做进程控制块的数据结构中&#xff0c;简称…...

NoSQL 与 NewSQL 全面对比:如何选择适合你的数据库方案?

1. 引言 随着互联网业务的爆发式增长&#xff0c;传统关系型数据库&#xff08;RDBMS&#xff09;面临着越来越大的挑战。海量数据存储、高并发访问、低延迟响应等需求促使技术团队寻找更适合的解决方案。在这一背景下&#xff0c;NoSQL 和 NewSQL 作为两种不同方向的技术路线…...

在 MoonBit 中引入 Elm 架构:用简单原则打造健壮的 Web 应用

Elm 是一种纯函数式编程语言&#xff0c;专为构建前端 Web 应用程序而设计。它编译为 JavaScript&#xff0c;强调简洁性、性能和健壮性。 纯函数式的含义是函数没有副作用&#xff0c;这使得代码更易于理解和调试。通过强大的静态类型检查&#xff0c;Elm 确保应用程序不会抛…...

虚幻基础:ue引擎的碰撞

文章目录 碰撞&#xff1a;碰撞体间 运动后 产生碰撞的行为——由引擎负责&#xff0c;并向各自发送事件忽略重叠阻挡 碰撞体类型模式纯查询&#xff1a;不清楚具体作用可以阻挡 actor碰撞(武器&#xff1a;刀/子弹)子组件可以产生阻挡 角色的碰撞只有根组件可以阻挡&#xff0…...

「电商玩法」AI自动创作系统源码:商品图+视频+营销文案一键生成

—零代码搭建智能内容工厂&#xff0c;1人日更1000条爆款素材 电商行业核心痛点 1. 内容产能不足 中小商家无力承担专业摄影/剪辑&#xff0c;商品图质量差→转化率<1%热点借势慢&#xff1a;竞品已开始推“淄博烧烤同款”&#xff0c;你的素材还在拍摄中 2. 成本居高不下…...

图形变换算法

一、学习目的 &#xff08;1&#xff09;掌握多面体的存储方法。 &#xff08;2&#xff09;掌握图形的几何变换及投影变换。 &#xff08;3&#xff09;掌握三维形体不同投影方法的投影图的生成原理。 &#xff08;4&#xff09;掌握多面体投影图绘制的编程方法。 二、学…...

no such window: target window already closed的解决方法

我在使用selenium 切换窗口的时候&#xff0c;由于不小心关闭了一个窗口&#xff0c;运行的时候就遇到这样的警告&#xff1a; no such window: target window already closed 具体的问题展示&#xff1a; 这个问题表示&#xff1a;当前的页面被关闭了&#xff0c;selenium 找…...

vue常见错误

1、 Cant resolve vant/lib/index.less 1. 未正确安装 Vant 首先&#xff0c;确保你已经正确安装了 Vant。可以通过以下命令来安装&#xff1a; npm install vant --save 或者使用 yarn&#xff1a; yarn add vant 2. LESS 加载器未配置 如果你在项目中使用了 Vant 的 L…...

chrome中的copy xpath 与copy full xpath的区别

学过测试或者爬虫的&#xff0c;都感觉获取网页元素&#xff0c;使用xpath最方便 但其中有一些细节可能会使你摸不清头脑 比如有时候copy xpath会定位不准确&#xff0c;而使用copy full xpath就可以定位 1、copy xpath&#xff08;相对路径定位&#xff09; 优点&#xff…...

【Docker】运行错误提示 unknown shorthand flag: ‘d‘ in -d ----详细解决方法

使用docker拉取Dify的时候遇到错误 错误提示 unknown shorthand flag: d in -dUsage: docker [OPTIONS] COMMAND [ARG...]错误原因解析 出现 unknown shorthand flag: d in -d 的根本原因是 Docker 命令格式与当前版本不兼容&#xff0c;具体分为以下两种情况&#xff1a; 新…...

VS Code 安装及常用插件

一、VS Code下载与安装 1、概述 Visual Studio Code简称VS Code&#xff0c;是一款功能强大的代码编辑器&#xff0c;与IDE&#xff08;集成开发环境&#xff09;不同&#xff0c;VS Code需要安装平台相应的编译器和语言的扩展。 IDE&#xff1a;是用于提供程序开发环境的应…...

iptables防火墙

目录 一 Linux防火墙基础 1 iptables的表&#xff0c;链结构 &#xff08;1&#xff09;规则表 filter 表 nat 表 mangle 表 raw 表 &#xff08;2&#xff09;规则链 2 数据包过滤的匹配流程 &#xff08;1&#xff09;规则表之间的顺序 &#xff08;2&#xff09;…...

【JavaWeb】详细讲解 HTTP 协议

文章目录 一、HTTP简介1.1 概念1.2 特点 二、协议2.1 HTTP-请求协议&#xff08;1&#xff09;GET方式&#xff08;2&#xff09;POST方式&#xff08;3&#xff09;GET和POST的区别&#xff1a; 2.2 HTTP-响应协议&#xff08;1&#xff09;格式&#xff08;2&#xff09;响应…...